text
stringlengths 49
983k
|
|---|
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[200005];
int b[200005];
vector<int> adj[200005];
bool removed[200005];
int nc[200005];
int ans[200005];
set<pair<int, int>> remedges;
int main() {
ios::sync_with_stdio(false);
scanf("%d %d %d", &n, &m, &k);
for (int i = 0; i < m; i++) {
scanf("%d %d", &a[i], &b[i]);
}
for (int i = 0; i < m; i++) {
adj[a[i]].push_back(b[i]);
adj[b[i]].push_back(a[i]);
nc[a[i]]++;
nc[b[i]]++;
}
int cans = n;
for (int i = 1; i <= n; i++) {
if (!removed[i]) {
if (nc[i] < k) {
removed[i] = true;
cans--;
queue<int> q;
q.push(i);
while (!q.empty()) {
int cur = q.front();
q.pop();
for (int j = 0; j < adj[cur].size(); j++) {
int x = adj[cur][j];
if (!removed[x]) {
nc[x]--;
if (nc[x] < k) {
removed[x] = true;
cans--;
q.push(x);
}
}
}
}
}
}
}
ans[m - 1] = cans;
for (int cm = m - 1; cm >= 0; cm--) {
int ca = a[cm];
int cb = b[cm];
if (!removed[ca] && !removed[cb]) {
nc[ca]--;
nc[cb]--;
remedges.insert(make_pair(ca, cb));
remedges.insert(make_pair(cb, ca));
if (nc[ca] < k) {
removed[ca] = true;
cans--;
queue<int> q;
q.push(ca);
while (!q.empty()) {
int cur = q.front();
q.pop();
for (int j = 0; j < adj[cur].size(); j++) {
int x = adj[cur][j];
if (remedges.find(make_pair(cur, x)) != remedges.end()) {
continue;
}
if (!removed[x]) {
nc[x]--;
if (nc[x] < k) {
removed[x] = true;
cans--;
q.push(x);
}
}
}
}
}
if (nc[cb] < k && !removed[cb]) {
removed[cb] = true;
cans--;
queue<int> q;
q.push(cb);
while (!q.empty()) {
int cur = q.front();
q.pop();
for (int j = 0; j < adj[cur].size(); j++) {
int x = adj[cur][j];
if (remedges.find(make_pair(cur, x)) != remedges.end()) {
continue;
}
if (!removed[x]) {
nc[x]--;
if (nc[x] < k) {
removed[x] = true;
cans--;
q.push(x);
}
}
}
}
}
}
if (cm > 0) {
ans[cm - 1] = cans;
}
}
for (int i = 0; i < m; i++) {
printf("%d\n", ans[i]);
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
long long powmod(long long a, long long b, long long mod) {
long long res = 1;
a %= mod;
assert(b >= 0);
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res % mod;
}
const int N = 2e5 + 10;
int degree[N];
vector<pair<int, int> > v[N];
bool mark[N];
set<pair<int, int> > s;
int main() {
memset(mark, 1, sizeof mark);
int n, m, k;
cin >> n >> m >> k;
vector<pair<int, int> > edges(m);
for (int i = 0; i < m; ++i) {
int a, b;
scanf("%d %d", &a, &b);
a--, b--;
edges[i].first = a;
edges[i].second = b;
degree[a]++;
degree[b]++;
v[a].push_back(make_pair(b, i));
v[b].push_back(make_pair(a, i));
}
for (int i = 0; i < n; ++i) {
s.insert(make_pair(degree[i], i));
}
while (!s.empty() && s.begin()->first < k) {
int u = s.begin()->second;
for (int i = 0; i < v[u].size(); ++i) {
int ch = v[u][i].first;
if (mark[ch]) {
s.erase(make_pair(degree[ch], ch));
degree[ch]--;
s.insert(make_pair(degree[ch], ch));
}
}
s.erase(make_pair(degree[u], u));
mark[u] = 0;
}
vector<int> ans;
for (int i = m - 1; i >= 0; --i) {
ans.push_back(s.size());
int a = edges[i].first, b = edges[i].second;
if (mark[a] && mark[b]) {
s.erase(make_pair(degree[a], a));
degree[a]--;
s.insert(make_pair(degree[a], a));
s.erase(make_pair(degree[b], b));
degree[b]--;
s.insert(make_pair(degree[b], b));
while (!s.empty() && (s.begin()->first < k)) {
int u = s.begin()->second;
for (int j = 0; j < v[u].size(); ++j) {
int ch = v[u][j].first, id = v[u][j].second;
if (id >= i) continue;
if (mark[ch]) {
s.erase(make_pair(degree[ch], ch));
degree[ch]--;
s.insert(make_pair(degree[ch], ch));
}
}
s.erase(make_pair(degree[u], u));
mark[u] = 0;
}
}
}
for (int i = ans.size() - 1; i >= 0; --i) {
printf("%d\n", ans[i]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
string to_string(string s) { return '"' + s + '"'; }
string to_string(char s) { return string(1, s); }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A>
string to_string(A);
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
bool f = 1;
string r = "{";
for (const auto &x : v) {
if (!f) r += ", ";
f = 0;
r += to_string(x);
}
return r + "}";
}
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cout << " " << to_string(H);
debug_out(T...);
}
inline int add(int a, int b) {
a += b;
if (a >= MOD) a -= MOD;
return a;
}
inline int sub(int a, int b) {
a -= b;
if (a < 0) a += MOD;
return a;
}
inline int mul(int a, int b) { return (int)((long long)a * b % MOD); }
inline int binpow(int a, int b) {
int res = 1;
while (b > 0) {
if (b & 1) res = mul(res, a);
a = mul(a, a);
b /= 2;
}
return res;
}
inline int inv(int a) { return binpow(a, MOD - 2); }
int gcd(int a, int b, int &x, int &y) {
if (a == 0) {
x = 0, y = 1;
return b;
}
int x1, y1;
int d = gcd(b % a, a, x1, y1);
x = y1 - (b / a) * x1;
y = x1;
return d;
}
const int N = 2e5 + 5;
int n, m, k, deg[N], ans[N];
vector<pair<int, int> > edges;
set<int> g[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m >> k;
for (int i = 0; i < m; ++i) {
int x, y;
cin >> x >> y;
edges.push_back({x, y});
deg[x]++;
deg[y]++;
g[x].insert(y);
g[y].insert(x);
}
int rem = n;
queue<int> q;
for (int i = 1; i <= n; ++i)
if (deg[i] < k) {
q.push(i);
rem--;
}
for (int i = m - 1; i >= 0; --i) {
while (!q.empty()) {
int v = q.front();
q.pop();
for (int u : g[v]) {
deg[u]--;
g[u].erase(v);
if (deg[u] == k - 1) {
q.push(u);
rem--;
}
}
deg[v] = 0;
g[v].clear();
}
ans[i] = rem;
int x = edges[i].first, y = edges[i].second;
if (!g[x].count(y)) continue;
deg[x]--;
deg[y]--;
g[x].erase(y);
g[y].erase(x);
if (deg[x] == k - 1) {
q.push(x);
rem--;
}
if (deg[y] == k - 1) {
q.push(y);
rem--;
}
}
for (int i = 0; i < m; ++i) cout << ans[i] << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int mxN = 2e5;
int n, m, k, eu[mxN], ev[mxN], ans[mxN];
set<int> adj[mxN];
bool a[mxN];
vector<int> tp;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> k;
for (int i = 0; i < m; ++i) {
cin >> eu[i] >> ev[i], --eu[i], --ev[i];
adj[eu[i]].insert(i);
adj[ev[i]].insert(i);
a[i] = 1;
}
for (int i = 0; i < n; ++i)
if (adj[i].size() < k) tp.push_back(i);
for (int i = m - 1; i >= 0; --i) {
ans[i] = i < m - 1 ? ans[i + 1] : n;
for (int j = 0; j < tp.size(); ++j) {
for (int e : adj[tp[j]]) {
adj[eu[e] ^ ev[e] ^ tp[j]].erase(e);
if (adj[eu[e] ^ ev[e] ^ tp[j]].size() == k - 1)
tp.push_back(eu[e] ^ ev[e] ^ tp[j]);
a[e] = 0;
}
adj[tp[j]].clear();
--ans[i];
}
tp.clear();
if (a[i]) {
adj[eu[i]].erase(i);
if (adj[eu[i]].size() < k) tp.push_back(eu[i]);
adj[ev[i]].erase(i);
if (adj[ev[i]].size() < k) tp.push_back(ev[i]);
a[i] = 0;
}
}
for (int i = 0; i < m; ++i) cout << ans[i] << "\n";
}
|
#include <bits/stdc++.h>
using namespace std;
int n, m, d[200005], k, res, vs[200005], ans[200005], pa;
map<int, int> cnt[200005];
vector<int> ke[200005];
pair<int, int> a[200005];
void dfs(int u) {
d[u]--;
res--;
vs[u] = 1;
for (int v : ke[u])
if (vs[v] == 0) {
cnt[u][v] = cnt[v][u] = 1;
d[v]--;
if (d[v] < k) {
d[v]++;
dfs(v);
}
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n >> m >> k;
res = n;
for (int i = 1; i <= m; i++) {
cin >> a[i].first >> a[i].second;
d[a[i].first]++;
d[a[i].second]++;
ke[a[i].first].push_back(a[i].second);
ke[a[i].second].push_back(a[i].first);
}
for (int i = 1; i <= n; i++)
if (d[i] < k && vs[i] == 0) dfs(i);
for (int i = m; i >= 1; i--) {
ans[i] = res;
ke[a[i].first].pop_back();
ke[a[i].second].pop_back();
if (cnt[a[i].first][a[i].second] == 1) continue;
if (vs[a[i].first] == 0) {
d[a[i].first]--;
if (d[a[i].first] < k) {
d[a[i].first]++;
dfs(a[i].first);
}
}
if (vs[a[i].second] == 0) {
d[a[i].second]--;
if (d[a[i].second] < k) {
d[a[i].second]++;
dfs(a[i].second);
}
}
}
for (int i = 1; i <= m; i++) cout << ans[i] << '\n';
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5;
set<int> g[MAXN];
int n, m, k;
int result = 0;
bool removed[MAXN];
int c[MAXN];
int edges[MAXN][2];
queue<int> q;
void remove_item(int m) {
result--;
q.push(m);
removed[m] = true;
}
void clear_queue() {
while (!q.empty()) {
auto to = q.front();
q.pop();
for (auto u : g[to]) {
c[u]--;
if (c[u] < k && !removed[u]) remove_item(u);
}
}
}
void remove_edge(int a, int b) {
g[a].erase(b);
g[b].erase(a);
}
int main() {
scanf("%d %d %d", &n, &m, &k);
for (int i = 0; i < m; i++) {
int a, b;
scanf("%d %d", &a, &b);
a--;
b--;
edges[i][0] = a;
edges[i][1] = b;
g[a].insert(b);
g[b].insert(a);
c[a]++;
c[b]++;
}
for (int i = 0; i < n; i++) {
if (c[i] < k) remove_item(i);
}
clear_queue();
vector<int> result_reversed;
result_reversed.push_back(n + result);
for (int i = m - 1; i > 0; i--) {
int a = edges[i][0];
int b = edges[i][1];
if (removed[a] || removed[b]) {
result_reversed.push_back(n + result);
continue;
}
c[a]--;
c[b]--;
g[a].erase(b);
g[b].erase(a);
if (c[a] < k) remove_item(a);
if (c[b] < k && !removed[b]) remove_item(b);
clear_queue();
result_reversed.push_back(n + result);
}
for (int i = m - 1; i >= 0; i--) {
printf("%d\n", result_reversed[i]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int deg[200010];
vector<vector<int> > graph(200010);
map<pair<int, int>, int> edgeNum;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int tt = 1;
while (tt--) {
int n, m, k;
cin >> n >> m >> k;
int x[m], y[m];
for (int i = 0; i < m; i++) {
cin >> x[i] >> y[i];
edgeNum[{x[i], y[i]}] = i;
edgeNum[{y[i], x[i]}] = i;
graph[x[i]].push_back(y[i]);
graph[y[i]].push_back(x[i]);
deg[x[i]]++;
deg[y[i]]++;
}
set<pair<int, int> > s;
for (int i = 1; i <= n; i++) {
s.insert({deg[i], i});
}
set<int> removed;
while (!s.empty()) {
pair<int, int> tmp = *s.begin();
s.erase(tmp);
int ver = tmp.second;
if (tmp.first >= k) {
s.insert(tmp);
break;
}
for (int i = 0; i < graph[ver].size(); i++) {
if (removed.count(edgeNum[{graph[ver][i], ver}]) == 1) continue;
removed.insert(edgeNum[{graph[ver][i], ver}]);
s.erase({deg[graph[ver][i]], graph[ver][i]});
deg[graph[ver][i]]--;
s.insert({deg[graph[ver][i]], graph[ver][i]});
}
}
int ans[m];
for (int ii = m - 1; ii >= 0; --ii) {
ans[ii] = s.size();
if (s.count({deg[x[ii]], x[ii]}) == 0 ||
s.count({deg[y[ii]], y[ii]}) == 0)
continue;
s.erase({deg[x[ii]], x[ii]});
s.erase({deg[y[ii]], y[ii]});
deg[x[ii]]--;
deg[y[ii]]--;
removed.insert(edgeNum[{x[ii], y[ii]}]);
s.insert({deg[x[ii]], x[ii]});
s.insert({deg[y[ii]], y[ii]});
while (!s.empty() && ((*s.begin()).first) < k) {
pair<int, int> tmp = *s.begin();
s.erase(tmp);
int ver = tmp.second;
if (tmp.first >= k) {
s.insert(tmp);
break;
}
for (int i = 0; i < graph[ver].size(); i++) {
if (removed.count(edgeNum[{graph[ver][i], ver}]) == 1) continue;
s.erase({deg[graph[ver][i]], graph[ver][i]});
removed.insert(edgeNum[{graph[ver][i], ver}]);
deg[graph[ver][i]]--;
s.insert({deg[graph[ver][i]], graph[ver][i]});
}
}
}
for (int i = 0; i < m; i++) {
cout << ans[i] << '\n';
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int maxm = 2e5 + 10;
const int INF = 0x3f3f3f3f;
struct Edge {
int v, next, id;
} edge[maxm * 2];
int n, m, k, res;
int U[maxn], V[maxn], du[maxn], Ans[maxn];
int head[maxn], cnt;
queue<int> q;
bool vis[maxn];
bool ok[maxn];
void add(int u, int v, int id) {
edge[cnt].next = head[u];
edge[cnt].v = v;
edge[cnt].id = id;
head[u] = cnt++;
}
void Bfs(int zz) {
while (!q.empty()) {
int x = q.front();
q.pop();
for (int i = head[x]; i != -1; i = edge[i].next) {
int v = edge[i].v;
if (vis[edge[i].id]) continue;
du[v]--;
vis[edge[i].id] = 1;
if (du[v] < k) {
if (!ok[v]) {
q.push(v);
Ans[zz]--;
ok[v] = 1;
}
}
}
}
}
int main() {
while (scanf("%d%d%d", &n, &m, &k) != EOF) {
memset(du, 0, sizeof(du));
memset(ok, 0, sizeof(ok));
memset(vis, 0, sizeof(vis));
memset(head, -1, sizeof(head));
cnt = 0;
while (!q.empty()) q.pop();
for (int i = 1; i <= m; i++) {
scanf("%d%d", U + i, V + i);
du[U[i]]++;
du[V[i]]++;
add(U[i], V[i], i);
add(V[i], U[i], i);
}
for (int i = 1; i <= n; i++) {
if (du[i] < k) {
q.push(i);
ok[i] = 1;
}
}
Bfs(m);
Ans[m] = 0;
for (int i = 1; i <= n; i++)
if (!ok[i]) Ans[m]++;
for (int i = m; i >= 1; i--) {
Ans[i - 1] = Ans[i];
if (vis[i]) {
continue;
}
du[U[i]]--;
du[V[i]]--;
vis[i] = 1;
if (du[U[i]] < k) {
if (!ok[U[i]]) {
q.push(U[i]);
Ans[i - 1]--;
ok[U[i]] = 1;
}
}
if (du[V[i]] < k) {
if (!ok[V[i]]) {
q.push(V[i]);
Ans[i - 1]--;
ok[V[i]] = 1;
}
}
Bfs(i - 1);
}
for (int i = 1; i <= m; i++) printf("%d\n", Ans[i]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long int LINF = 0x3f3f3f3f3f3f3f3fll;
int t, n, a, b, cnt1, cnt2;
string s;
int main() {
cin >> n;
cin >> s;
cnt1 = n / 11;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '8') cnt2++;
}
cout << min(cnt1, cnt2) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char c;
int n, cnt = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> c;
if (c == '8') cnt++;
}
cout << min(cnt, n / 11) << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, count = 0;
cin >> n;
string s;
cin >> s;
char c = '8';
for (int i = 0; i < n; i++) {
if (s[i] == c) count++;
}
cout << min(count, n / 11);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, temp = 0, temp1 = 0;
cin >> n;
string s;
cin >> s;
for (int i = 0; i < s.length(); i++) {
if (s[i] == '8') temp++;
}
for (int i = 1; i <= temp; i++) {
int r = (n - i) / 10;
if (r >= i) {
temp1++;
} else
break;
}
cout << temp1;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n;
cin >> n;
int arr[10] = {};
for (int i = 0; i < n; i++) {
char c;
cin >> c;
arr[c - '0']++;
}
cout << min(n / 11, arr[8]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, max = 0;
string str;
cin >> n;
cin >> str;
for (int i = 0; i < n; i++) {
if (str[i] == '8') {
max++;
}
}
if (max > n / 11) {
max = n / 11;
}
if (n % 11 != 0 && max > n / 11) {
max = n / 11;
}
cout << max;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int eig = 0, oth = 0, num = 0;
int n;
cin >> n;
char tab[n];
string cards;
cin >> cards;
for (int i = 0; i < n; i++) tab[i] = cards.at(i);
for (int i = 0; i < n; i++) {
if (tab[i] == '8') eig++;
}
oth = n;
while ((oth > 10) && (eig > 0)) {
num++;
eig--;
oth -= 11;
}
cout << num;
}
|
#include <bits/stdc++.h>
using namespace std;
long long powmod(long long a, long long b, long long mod) {
if (b == 0 || a == 1) {
if (mod == 1)
return 0;
else
return 1;
}
if (b % 2 == 0) {
long long k = powmod(a, b / 2, mod);
return (k * k) % mod;
} else {
long long k = powmod(a, b / 2, mod);
return ((k * k) % mod * a) % mod;
}
}
long long gcd(long long a, long long b) {
if (a == 0) return b;
if (b == 0) return a;
if (a > b)
return gcd(a % b, b);
else
return gcd(b % a, a);
}
int prime(int p) {
for (int i = 2; i * i <= p; i++) {
if (p % i == 0 && i < p) return i;
}
return 1;
}
long long sqr(long long i) { return i * i; }
void r(long long &a) { cin >> a; }
void r(long long &a, long long &b) { cin >> a >> b; }
void r(long long &a, long long &b, long long &c) { cin >> a >> b >> c; }
void r(long long &a, long long &b, long long &c, long long &d) {
cin >> a >> b >> c >> d;
}
void r(long long &a, long long &b, long long &c, long long &d, long long &e) {
cin >> a >> b >> c >> d >> e;
}
void r(long long &a, long long &b, long long &c, long long &d, long long &e,
long long &f) {
cin >> a >> b >> c >> d >> e >> f;
}
void r(vector<long long> &a) {
for (int i = 0; i < a.size(); i++) r(a[i]);
}
void r(vector<vector<long long>> &a) {
for (int i = 0; i < a.size(); i++) r(a[i]);
}
void w(long long a) { cout << a << "\n"; }
void w(char a) { cout << a; }
void w(long long a, long long b) { cout << a << " " << b << "\n"; }
void w(long long a, long long b, long long c) {
cout << a << " " << b << " " << c << "\n";
}
void w(long long a, long long b, long long c, long long d) {
cout << a << " " << b << " " << c << " " << d << "\n";
}
void w(vector<long long> a) {
for (int i = 0; i < a.size(); i++) cout << a[i] << " ";
cout << "\n";
}
void w(vector<vector<long long>> a) {
for (int i = 0; i < a.size(); i++) w(a[i]);
cout << "\n";
}
void r(pair<long long, long long> &a) { cin >> a.first >> a.second; }
void w(pair<long long, long long> a) {
cout << a.first << " " << a.second << "\n";
}
void r(vector<pair<long long, long long>> &a) {
for (int i = 0; i < a.size(); i++) r(a);
}
void w(vector<pair<long long, long long>> a) {
for (int i = 0; i < a.size(); i++) w(a[i]);
cout << "\n";
}
void r(string &a) { cin >> a; }
void r(char &a) { cin >> a; }
void w(string a) { cout << a << "\n"; }
void sort(vector<long long> &a) { sort(a.begin(), a.end()); }
void sort(vector<pair<long long, long long>> &a) { sort(a.begin(), a.end()); }
void rev(vector<long long> &a) { reverse(a.begin(), a.end()); }
void rev(vector<pair<long long, long long>> &a) { reverse(a.begin(), a.end()); }
void rev(string &a) { reverse(a.begin(), a.end()); }
void solve(int ppppppppp = 1) {
long long a;
string s;
r(a);
r(s);
long long num = 0;
for (int i = 0; i < a; i++) num += s[i] == '8';
w(min(num, a / 11));
return;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tututu;
tututu = 1;
for (int qwerty = 0; qwerty < tututu; qwerty++) solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s;
cin >> s;
int cnt = 0, count = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '8') cnt++;
}
while (cnt) {
n = n - 1;
cnt = cnt - 1;
if (n / 10 > 0) {
count++;
n = n - 10;
}
}
cout << count;
}
|
#include <bits/stdc++.h>
int c[10];
using namespace std;
int main() {
int n;
scanf("%d", &n);
int a[n], i;
string s;
cin >> s;
for (i = 0; i < n; i++) {
c[s[i] - '0']++;
}
int ans = 0;
for (i = 1; i <= c[8]; i++) {
if ((n - i) >= 10 * i) ans = i;
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, n, cnt = 0, temp;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%01d", &temp);
if (temp == 8) cnt++;
}
printf("%d\n", min(cnt, n / 11));
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, countOfEight = 0, alongNums = 0;
string input;
cin >> n >> input;
for (int i = 0; i < n; i++) {
char cha = input[i];
if (cha == '8') countOfEight++;
}
alongNums = n - countOfEight;
while (alongNums / 10 < countOfEight) {
alongNums++;
countOfEight--;
}
if (alongNums < 10 || countOfEight == 0)
cout << 0;
else {
alongNums /= 10;
if (alongNums >= countOfEight)
cout << countOfEight;
else {
cout << alongNums;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 110;
int main(int argc, char const *argv[]) {
char s[MAX_N];
int n;
int eight = 0;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> s[i];
if (s[i] == '8') eight++;
}
cout << min(eight, n / 11) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long int a, b, m, n, i, j, k, l, cnt = 0, ans, Min;
char c[113];
cin >> n;
for (i = 1; i <= n; i++) {
cin >> c[i];
if (c[i] == '8') {
cnt++;
}
}
ans = n / 11;
Min = min(ans, cnt);
cout << Min << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int num[10];
int main() {
cin >> n;
cin >> s;
int c = 0;
for (int i = 0; i < n; i++) {
num[s[i] - '0']++;
if (s[i] != '8') c++;
}
int ans = 0;
while (num[8] >= 0) {
ans = max(ans, min(num[8], c / 10));
num[8]--;
c++;
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
int n;
int a[maxn], b[maxn];
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
x = x * 10 + ch - '0';
return x * f;
}
inline void writ(int x) {
if (x < 0) putchar('-'), x = -x;
if (x > 9) writ(x / 10);
putchar(x % 10 + '0');
}
inline void write(int x) {
writ(x);
putchar('\n');
}
inline void writt(int x) {
writ(x);
putchar(' ');
}
int main() {
int ans = 0;
scanf("%d", &n);
for (int i = 1; i <= n; ++i) a[i] = read(), ++b[a[i]];
for (int i = 1; i <= b[8]; ++i) {
int t = min(i, (n - i) / 10);
ans = max(ans, t);
}
write(ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
char a[105];
int ans = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == '8') ans++;
}
if (n < 11 || ans == 0) {
cout << 0 << endl;
return 0;
}
if (ans >= n / 11)
cout << n / 11 << endl;
else
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
int n1 = 0, n2 = 0, n3 = 0;
string s;
cin >> n;
cin >> s;
for (int i = 0; i < n; i++) {
if (s[i] == '8') n1++;
}
n2 = n / 11;
if (n1 == 0 || s.size() < 8) {
cout << "0" << endl;
return 0;
}
cout << min(n2, n1) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f, mod = 1000000007;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const double pi = acosl(-1.), eps = 1e-9;
inline int power(int a, int b, int m = mod, int ans = 1) {
for (; b; b >>= 1, a = 1LL * a * a % m)
if (b & 1) ans = 1LL * ans * a % m;
return ans;
}
int cnt;
int main() {
int n;
cin >> n;
for (int i = 0, d; i < n; i++) {
scanf("%1d", &d);
if (d == 8) cnt++;
}
int ans = 0;
for (int i = 1; i <= cnt; i++) {
if ((n - i) >= i * 10) ans = i;
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, x, a;
string s;
int main() {
cin >> n >> s;
for (int i = 0; i < n; ++i) {
if (s[i] == '8') {
x++;
}
}
a = n / 11;
cout << min(a, x);
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int main() {
cin >> n >> s;
int x = count(s.begin(), s.end(), '8');
cout << min(n / 11, x);
}
|
#include <bits/stdc++.h>
int main(void) {
int n;
char s[100], dummy[1];
int number = 0;
scanf("%d", &n);
gets(dummy);
gets(s);
if (strlen(s) != n) {
printf("%d", number);
} else {
for (int i = 0; i < n; i++) {
if (s[i] == '0' || s[i] == '1' || s[i] == '2' || s[i] == '3' ||
s[i] == '4' || s[i] == '5' || s[i] == '6' || s[i] == '7' ||
s[i] == '8' || s[i] == '9') {
if (s[i] == '8') {
number++;
if (number > n / 11) {
number--;
break;
}
}
} else
break;
}
printf("%d", number);
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long max3 = 1003;
const long long max4 = 10004;
const long long max5 = 100005;
const long long max6 = 1000006;
const long long max7 = 10000007;
const long long lg4 = 13;
const long long lg5 = 17;
const long long lg6 = 20;
const long long INF = 2LL * 1000000000;
const long long INFLL = 9LL * 1000000000 * 1000000000;
const long long M = 1e9 + 7;
long long powmod(long long a, long long b, long long mod) {
long long res = 1;
a %= mod;
for (; b; b >>= 1) {
if (b & 1) res = (res * a) % mod;
a = (a * a) % mod;
}
return res;
}
long long gcd(long long a, long long b) {
while (b > 0) {
long long t = a % b;
a = b, b = t;
}
return a;
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
long long is_prime(long long n) {
if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0)) return 0;
for (long long i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
if (n % i == 0) return 0;
return 1;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
if (fopen("input.txt", "r")) {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
}
int n;
cin >> n;
string s;
cin >> s;
int cnt = 0;
for (int i = 0; i < n; i++)
if (s[i] == '8') cnt++;
int sets = n / 11;
cout << min(sets, cnt) << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
string a;
cin >> a;
int ans = 0;
for (int i = 0; i < n; ++i) {
ans += (a[i] == '8');
}
cout << min(ans, n / 11) << "\n";
}
|
#include <bits/stdc++.h>
using namespace std;
void Letters() {
int n, m;
cin >> n >> m;
vector<int64_t> houses;
vector<int64_t> letters;
vector<int64_t> apart;
for (int i = 0; i < n; i++) {
int64_t k;
cin >> k;
houses.push_back(k);
}
for (int i = 0; i < m; i++) {
int64_t k;
cin >> k;
letters.push_back(k);
}
apart.push_back(houses[0]);
for (int i = 1; i < n; i++) {
int64_t k = apart[i - 1];
k += houses[i];
apart.push_back(k);
}
int l = 0, r = letters.size() - 1;
int mid;
for (int i = 0; i < letters.size(); i++) {
int64_t need_to_found = letters[i];
if (need_to_found <= apart[0]) {
cout << "1 " << need_to_found << "\n";
} else {
l = 0;
r = apart.size() - 1;
while (l <= r) {
mid = static_cast<int>((l + r) / 2);
if (need_to_found < apart[mid]) {
r = mid - 1;
} else {
l = mid + 1;
}
}
if (l + 1 >= apart.size()) {
l = apart.size() - 1;
}
if (need_to_found - apart[l - 1]) {
cout << l + 1 << " " << need_to_found - apart[l - 1] << endl;
} else {
cout << l << " " << houses[l - 1] << endl;
}
}
}
}
void NewYear() {
int n, k;
cin >> n >> k;
int left = 240 - k;
int i;
for (i = 1; i <= n; i++) {
left -= i * 5;
if (left < 0) {
cout << i - 1 << endl;
return;
}
if (left == 0) {
cout << i << endl;
return;
}
}
cout << n << endl;
return;
}
void Frog() {
string s;
cin >> s;
int d = 1, min_d = 1;
int flag = 0;
for (char c : s) {
if (c == 'L') {
d++;
}
if (c == 'R') {
flag = 1;
if (min_d < d) {
min_d = d;
}
d = 1;
}
}
if (min_d < d) {
min_d = d;
}
cout << min_d << "\n";
return;
}
void StartTTests() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
Frog();
}
}
void ZeinInLove() {
int n, m, k;
cin >> n >> m >> k;
vector<int> houses;
for (int i = 0; i < n; i++) {
int house;
cin >> house;
houses.push_back(house);
}
int min_l = 0, min_r = 0;
int left_flag = 0, right_flag = 0;
for (int i = m - 2; i >= 0; i--) {
if (houses[i] <= k and houses[i] != 0) {
left_flag = 1;
break;
}
min_l += 10;
}
for (int i = m; i < n; i++) {
if (houses[i] <= k and houses[i] != 0) {
right_flag = 1;
break;
}
min_r += 10;
}
if ((min_l <= min_r and left_flag != 0) or (right_flag == 0)) {
cout << min_l + 10 << endl;
} else {
cout << min_r + 10 << endl;
}
}
void HappyBithdaySaja() {
int n;
cin >> n;
vector<int> price;
for (int i = 0; i < n; i++) {
int price_one;
cin >> price_one;
price.push_back(price_one);
}
sort(price.begin(), price.end());
for (int i = 1; i < n; i += 2) {
swap(price[i], price[i - 1]);
}
if (n % 2) {
cout << n / 2 << endl;
} else {
cout << n / 2 - 1 << endl;
}
for (int i = 0; i < n; i++) {
cout << price[i] << " ";
}
cout << endl;
}
void PhoneNumber() {
int n;
cin >> n;
string number;
cin >> number;
int count_8 = count(number.begin(), number.end(), '8');
int count_number = n / 11;
if (count_8 >= count_number) {
cout << count_number << endl;
} else {
cout << count_8 << endl;
}
}
int main() {
PhoneNumber();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s;
cin >> s;
int c = 0;
for (int i = 0; s[i] != '\0'; i++) {
if (s[i] == '8') c++;
}
cout << min(n / 11, c);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int k = n;
string s;
cin >> s;
int cn = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '8') cn++;
}
int rem = n / 11;
if (rem <= cn)
cout << rem;
else
cout << cn;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
string s;
while (cin >> n) {
cin >> s;
int cnt8 = 0;
for (int i = 0; i < n; i++)
if (s[i] == '8') cnt8++;
int n8 = n - cnt8;
int ans = min(n / 11, cnt8);
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n;
string second;
int cnt[1111];
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> n >> second;
for (int i = 0; i < n; ++i) {
cnt[second[i] - '0']++;
}
int x = cnt[8];
int sum = 0;
for (int i = 0; i <= 9; ++i) {
sum += cnt[i];
}
int ans = 0;
for (int i = 1; i <= x; ++i) {
if ((sum - i) >= 10 * i) ans = i;
}
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int count = 0;
int n;
string s;
cin >> n;
cin >> s;
for (int i = 0; i < n; ++i)
if (s[i] == '8') ++count;
printf("%d\n", min(n / 11, count));
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string str;
cin >> str;
int temp = 0;
for (int i = 0; i < n; i++) {
if (str[i] == '8') temp++;
}
int ans = min(n / 11, temp);
cout << ans;
}
|
#include <bits/stdc++.h>
using namespace std;
void swap(char *x, char *y) {
char temp;
temp = *x;
*x = *y;
*y = temp;
}
bool isPalindrome(char str[]) {
long long int l = 0;
long long int h = strlen(str) - 1;
while (h > l) {
if (str[l++] != str[h--]) {
return false;
}
}
return true;
}
long long int anagram(char input[], long long int n) {
long long int cnt = 0;
sort(input, input + n);
do {
cout << input << endl;
if (isPalindrome(input)) cnt++;
} while (next_permutation(input, input + n));
return cnt;
}
long long int permute(char *a, long long int l, long long int r) {
long long int i, cnt = 0;
if (l == r) {
cout << a << endl;
if (isPalindrome(a)) cnt++;
} else {
for (i = l; i <= r; i++) {
swap((a + l), (a + i));
permute(a, l + 1, r);
swap((a + l), (a + i));
}
}
return cnt;
}
int binarySearch(long long int arr[], int l, int r, int x) {
int last = r;
if (r >= l) {
int mid = l + (r - l) / 2;
if (x < arr[mid] && x >= arr[mid - 1]) {
return mid;
}
if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x);
return binarySearch(arr, mid + 1, r, x);
}
return -1;
}
int quadratic(int a, int b, int c) {
int x1, x2, discriminant;
discriminant = b * b - 4 * a * c;
if (discriminant > 0) {
x1 = (-b + sqrt(discriminant)) / (2 * a);
x2 = (-b - sqrt(discriminant)) / (2 * a);
if (x1 > 0)
return x1;
else
return x2;
}
}
void print_arr(unsigned long long int arr[], long long int n) {
long long int i;
for (i = 0; i < n; i++) {
cout << arr[i] << ' ';
}
cout << endl;
}
long long int bsearch(long long int prefixsum[], long long int n,
long long int k) {
long long int ans = -1;
long long int left = 1, right = n;
while (left <= right) {
long long int mid = (left + right) / 2;
long long int i, s = 0, dd;
for (i = mid; i <= n; i++) {
dd = prefixsum[i] - prefixsum[i - mid];
if (dd <= k) {
s = 1;
break;
}
}
if (s) {
left = mid + 1;
ans = max(mid, ans);
s = 0;
} else
right = mid - 1;
}
if (ans == -1) ans++;
return ans;
}
void scn_arr(long long int arr[], long long int n) {
long long int i;
for (i = 0; i < n; i++) {
scanf("%lld", &arr[i]);
}
}
long long int maxSizeBelowK(long long int arr[], long long int n,
long long int k) {
long long int prefixsum[n + 1], i;
memset(prefixsum, 0, sizeof(prefixsum));
for (i = 0; i < n; i++) prefixsum[i + 1] = prefixsum[i] + arr[i];
return bsearch(prefixsum, n, k);
}
long long int GCD(long long int a, long long int b) {
if (b == 0) return a;
return GCD(b, a % b);
}
long long int LCM(long long int a, long long int b) {
return b * a / GCD(a, b);
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
return (a.second < b.second);
}
bool *SieveOfEratosthenes(int n, bool *prime) {
for (int p = 2; p * p <= n; p++) {
if (prime[p] == true) {
for (int i = p * 2; i <= n; i += p) prime[i] = false;
}
}
return prime;
}
bool isPrime(long long int n) {
long long int i, h;
if (n <= 1) return false;
if (n == 2) return true;
if (n % 2 == 0) return false;
h = sqrt(n);
for (i = 3; i <= h; i += 2) {
if (n % i == 0) {
return false;
}
}
return true;
}
void combinationUtil(long long int arr[], long long int n, long long int r,
long long int index, long long int data[],
long long int i) {
if (index == r) {
for (int j = 0; j < r; j++) printf("%d ", data[j]);
printf("\n");
return;
}
if (i >= n) return;
data[index] = arr[i];
combinationUtil(arr, n, r, index + 1, data, i + 1);
combinationUtil(arr, n, r, index, data, i + 1);
}
long long int countBits(long long int number) {
return (long long int)log2(number) + 1;
}
void printCombination(long long int arr[], long long int n, long long int r) {
long long int data[r];
combinationUtil(arr, n, r, 0, data, 0);
}
long long int ASCIIofString(string str) {
long long int sum = 0;
long long int len = str.length();
for (long long int i = 0; i < len; i++) sum += (int)str[i];
return sum;
}
bool isPowerOfTwo(long long int x) { return (x && !(x & (x - 1))); }
int leftRotate(int n, unsigned int d) { return (n << d) | (n >> (7 - d)); }
void leftRotatebyOne(string s, long long int n) {
long long int i;
char temp = s[0];
for (i = 0; i < n - 1; i++) s[i] = s[i + 1];
s[i] = temp;
}
long long int lowestSetBit(long long int num) { return (num & (-num)); }
long long int countSetBits(long long int num) {
long long int cnt = 0;
while (num) {
num &= (num - 1);
cnt++;
}
return cnt;
}
long long int toggleBit(long long int num, long long int pos) {
return num ^ (1 << pos);
}
int _lis(int arr[], int n, int *max_ref) {
if (n == 1) return 1;
int res, max_ending_here = 1;
for (int i = 1; i < n; i++) {
res = _lis(arr, i, max_ref);
if (arr[i - 1] < arr[n - 1] && res + 1 > max_ending_here)
max_ending_here = res + 1;
}
if (*max_ref < max_ending_here) *max_ref = max_ending_here;
return max_ending_here;
}
int lis(int arr[], int n) {
int max = 1;
_lis(arr, n, &max);
return max;
}
int lds(int arr[], int n) {
int lds[n];
int i, j, max = 0;
for (i = 0; i < n; i++) lds[i] = 1;
for (i = 1; i < n; i++)
for (j = 0; j < i; j++)
if (arr[i] < arr[j] && lds[i] < lds[j] + 1) lds[i] = lds[j] + 1;
for (i = 0; i < n; i++)
if (max < lds[i]) max = lds[i];
return max;
}
void factArr(long long int n, unsigned long long int *arr, long long int mod) {
for (long long int i = 0; i <= n; i++) {
if (!i || i == 1)
arr[i] = 1;
else if ((arr[i - 1] * i) % mod == 0)
arr[i] = 1;
else
arr[i] = (arr[i - 1] * i) % mod;
}
}
unsigned long long int fastPow(long long int x, unsigned long long int y,
long long int p) {
long long int res = 1;
x = x % p;
while (y > 0) {
if (y & 1) res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
int main() {
long long int cnt8 = 0, n, i, num;
string nums;
cin >> n;
cin >> nums;
num = n / 11;
for (i = 0; i < n; i++) {
if (nums[i] == '8') cnt8++;
}
if (n < 11 || !cnt8)
cout << "0";
else
cout << min(cnt8, num);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
void dance() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
void file() {
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
}
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
template <typename t>
void printV(vector<t> v) {
for (int i = 0; i < v.size(); i++) {
cout << v[i] << ' ';
}
cout << endl;
}
bool isPrime(int n) {
if (n == 2) return true;
if (n < 2 || n % 2 == 0) return false;
for (int i = 3; i * i <= n; i += 2)
if (n % i == 0) return false;
return true;
}
int main() {
dance();
int n;
cin >> n;
string s;
cin >> s;
int e = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '8') e++;
}
cout << min(e, n / 11) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 5;
const long long int M = 1e9 + 7;
queue<pair<long long int, long long int> > pq;
vector<long long int> v;
map<long long int, long long int> mpp;
set<pair<long long int, long long int> > st;
long long int a[N], h[N], indx[N][2];
long long int val[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
long long int n, l;
cin >> n;
string s;
cin >> s;
long long int a = 0;
long long int b = 0;
for (int i = int(0); i <= int(n - 1); i++) {
if (s[i] == '8') a++;
}
long long int x = n / 11;
if (a < x)
cout << a;
else
cout << x;
}
|
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double maxn = 1e10 + 10;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int main() {
int n, sum = 0;
cin >> n;
string s;
cin >> s;
for (int i = 0; i <= n - 1; i++) {
if (s[i] == '8') {
sum++;
}
}
int t = n / 11;
cout << min(t, sum) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, count = 0;
cin >> n;
string cards;
if (n < 11) {
cout << "0" << endl;
return 0;
} else {
cin >> cards;
for (int i = 0; i < n; i++) {
if (cards[i] == '8') count++;
}
int k = n / 11;
if (count >= k)
cout << k << endl;
else
cout << count << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
string s;
int b[10];
int main() {
int t, n, i, j;
scanf("%d", &n);
cin >> s;
int c = 0;
for (i = 0; i < n; i++) {
if (s[i] == '8') {
c++;
}
}
if (c == 0) {
printf("0\n");
} else {
printf("%d\n", min(c, n / 11));
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
clock_t clk_begin = clock();
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
string s;
cin >> s;
int c = 0;
for (int i = 0; i < n; ++i)
if (s[i] == '8') c++;
n /= 11;
cout << min(n, c) << '\n';
;
cerr << "Time taken: " << (double)(clock() - clk_begin) / CLOCKS_PER_SEC
<< '\n';
return 0;
;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int sum = 0;
char s;
for (int i = 0; i < n; i++) {
cin >> s;
if (s == '8') sum++;
}
sum = min(sum, n / 11);
cout << sum << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, cnt8;
char s[110];
int main() {
cin >> n;
cnt8 = 0;
scanf("%s", s + 1);
for (int i = 1; i <= n; ++i)
if (s[i] == '8') ++cnt8;
int ans = 0;
while (cnt8 > 0 && n >= 11) ++ans, --cnt8, n -= 11;
printf("%d\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, temp = 0, num = 0;
char x[105];
int main() {
cin >> n;
scanf("%s", &x);
for (int i = 0; i < n; i++) {
if (x[i] == '8') temp++;
}
num = min(n / 11, temp);
cout << num;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, eight;
string s;
int main() {
ios::sync_with_stdio(false);
cin >> n >> s;
for (char c : s) eight += (c == '8');
cout << min(n / 11, eight) << endl;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "inline", "-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
using namespace std;
int n;
int ans;
string s;
int main() {
cin >> n >> s;
for (auto c : s) ans += c == '8';
cout << min(ans, n / 11) << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
void cases() {
long long int n;
cin >> n;
string s;
cin >> s;
long long int c = 0;
for (long long int i = 0; i < n; i++) c += (s[i] == '8');
cout << min(c, n / 11);
}
int32_t main() {
std::ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int tc = 1;
while (tc--) {
cases();
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long double pi = 2 * acos(0.0);
template <class T>
bool umin(T& a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T>
bool umax(T& a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T, class TT>
bool pal(T a, TT n) {
int k = 0;
for (int i = 0; i <= n / 2; i++) {
if (a[i] != a[n - i - 1]) {
k = 1;
break;
}
}
return k ? 0 : 1;
}
int main() {
int n;
cin >> n;
string s;
cin >> s;
int cnt = 0;
for (int i = 0; i < s.size(); i++) cnt += (s[i] == '8');
cout << min(cnt, n / 11);
getchar();
getchar();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
char num[200];
int main() {
int n, ans = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> num[i];
if (num[i] == '8') ans++;
}
int sum = min(ans, n / 11);
cout << sum << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, count = 0;
cin >> n;
for (int i = 0; i < n; i++) {
char ch;
cin >> ch;
if (ch == '8') count++;
}
if (count == 0)
cout << 0;
else
cout << (count >= n / 11 ? n / 11 : count);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, cnt = 0;
string s;
cin >> n >> s;
for (int i = 0; i < s.size(); ++i) {
if (s[i] == '8') ++cnt;
}
cout << min(cnt, n / 11) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 111;
char s[N];
int main() {
int n;
scanf("%d %s", &n, s);
int ans = 0;
for (int i = 0; i < n; i++)
if (s[i] == '8') ans++;
ans = min(ans, n / 11);
printf("%d\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxi = 1e6 + 10;
int a[maxi];
string s;
int n;
int cnt[maxi];
int main() {
cin >> n;
cin >> s;
for (int i = 0; i < n; i++) cnt[s[i] - '0']++;
int mm = n / 11;
mm = min(mm, cnt[8]);
cout << mm << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
int main() {
int n;
string s;
cin >> n >> s;
int cnt = 0;
for (auto i : s) {
if (i == '8') cnt++;
}
int ans = 0;
while (cnt--) {
if (n < 11) break;
ans++;
n -= 11;
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cerr.tie(nullptr);
int n;
cin >> n;
string s;
cin >> s;
int a = 0, b = 0;
for (auto& i : s) {
if (i == '8')
++a;
else
++b;
}
int sol = 0;
while (a) {
if (b >= 10) {
b -= 10;
--a;
++sol;
} else {
if (b + a - 1 >= 10) {
a -= (11 - b);
b = 0;
++sol;
} else {
break;
}
}
}
cout << sol << '\n';
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, check = 0;
cin >> n;
char a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == '8') check++;
}
int k = n / 11;
if (k < check)
cout << k;
else
cout << check;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, cnt = 0;
string s;
cin >> n >> s;
for (int i = 0; i < n; i++)
if (s[i] == '8') cnt++;
cout << min(cnt, (n / 11));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
string str;
cin >> str;
int i, ans = 0;
for (i = 0; i < t; i++) {
if (str.at(i) == '8') ans++;
}
int k = t / 11;
if (ans > k || ans == k)
cout << k << endl;
else
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
int main() {
int n, count = 0, i, len;
char num[105];
scanf("%d ", &n);
gets(num);
len = strlen(num);
if (n >= 11) {
for (i = 0; i < len; i++) {
if (num[i] == '8') {
n -= 11;
if (n >= 0) {
count++;
continue;
} else
break;
}
}
printf("%d\n", count);
} else
printf("%d\n", 0);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long power(long long x, long long p, long long MOD) {
if (p == 0) return 1 % MOD;
if (p == 1) return x % MOD;
long long res = power(x, p / 2, MOD);
res = (long long)res * res % MOD;
if (p & 1) res = (long long)res * x % MOD;
return res;
}
int32_t main() {
long long n;
cin >> n;
string s;
cin >> s;
long long e = 0;
for (char c : s) {
e += c == '8';
}
long long ans = 0;
for (long long i = 1; i <= e; i++) {
ans = max(ans, min(i, (n - i) / 10));
}
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
char ch;
int cnt = 0;
for (int i = 1; i <= n; i++) {
cin >> ch;
int x = ch - '0';
if (x == 8) cnt++;
}
cout << min(cnt, n / 11);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
string x;
cin >> x;
int d = 0;
for (int i = 0; i < t; i++) {
if (x[i] == '8') {
d++;
}
}
if (t / 11 < d) {
cout << x.size() / 11;
} else {
cout << d;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int sonuc1, sonuc2, n, sayac1, sayac2;
string s;
int main() {
cin >> n;
cin >> s;
for (int i = 0; i < n; ++i) {
if (s[i] >= '0' and s[i] <= '9') {
sayac1++;
}
if (s[i] == '8') {
sayac2++;
}
}
if (sayac1 == n and sayac2 >= n / 11) {
cout << n / 11;
} else if (sayac2 < n / 11 and sayac2 > 0) {
cout << sayac2;
} else {
cout << 0;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct cww {
cww() {
if (1) {
ios::sync_with_stdio(false);
cin.tie(0);
}
}
} star;
template <typename T>
inline bool chmin(T &l, T r) {
bool a = l > r;
if (a) l = r;
return a;
}
template <typename T>
inline bool chmax(T &l, T r) {
bool a = l < r;
if (a) l = r;
return a;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
for (auto &it : v) is >> it;
return is;
}
class range {
private:
struct I {
int x;
int operator*() { return x; }
bool operator!=(I &lhs) { return x < lhs.x; }
void operator++() { ++x; }
};
I i, n;
public:
range(int n) : i({0}), n({n}) {}
range(int i, int n) : i({i}), n({n}) {}
I &begin() { return i; }
I &end() { return n; }
};
int main() {
int n;
cin >> n;
int k = 0;
string s;
cin >> s;
for (int i : range(n)) {
if (s[i] == '8') k++;
}
int ret = 0;
for (int i : range(n)) {
if (i <= k && n - i >= 10 * i) ret = i;
}
cout << ret << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, o = 0, c = 0;
string str;
cin >> n >> str;
for (int i = 0; i < n; i++) {
if (str[i] == '8')
c++;
else
o++;
}
cout << min(c, n / 11);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s;
cin >> s;
int a = 0;
for (int i = 0; i < n; ++i)
if (s[i] == '8') ++a;
cout << min(n / 11, a) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using vl = vector<ll>;
using pll = pair<ll, ll>;
using mll = map<ll, ll>;
using vvl = vector<vl>;
using md = double;
template <typename T>
istream& operator>>(istream& c, vector<T>& v) {
for (auto& i1 : v) c >> i1;
return c;
}
template <typename T1, typename T2>
istream& operator>>(istream& c, pair<T1, T2>& p) {
return c >> p.first >> p.second;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& c, pair<T1, T2> p) {
return c << p.first << ' ' << p.second;
}
const ll mod = 1000000007;
mt19937_64 rng(0xDEADBEEF);
template <typename T>
T binpow(T a, ll b, ll c = mod) {
if (b == 1) return a;
if (b & 1) return binpow(a, b - 1) * a % c;
T res = binpow(a, b >> 1);
return res * res % c;
}
namespace geom {
pll operator+(pll a, pll b) { return {a.first + b.first, a.second + b.second}; }
pll operator-(pll a, pll b) { return {a.first - b.first, a.second - b.second}; }
pll operator-(pll a) { return {-a.first, -a.second}; }
pll operator*(pll a) { return {-a.second, a.first}; }
ll operator*(pll a, pll b) { return a.first * b.first + a.second * b.second; }
} // namespace geom
int main() {
using namespace geom;
cin.sync_with_stdio(0);
cin.tie(0);
cout.sync_with_stdio(0);
cout.tie(0);
ll n;
cin >> n;
string s;
cin >> s;
cout << min<ll>(s.size() / 11, count(s.begin(), s.end(), '8'));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n = 0;
cin >> n;
int liczba_osemek = 0;
string s;
cin >> s;
if (s.size() < 8) {
cout << "0";
return 0;
} else
for (int i = 0; i < n; i++) {
if (s[i] == '8') liczba_osemek++;
}
if (liczba_osemek == 0) {
cout << "0";
return 0;
}
int liczba_jedenastek = n / 11;
if (liczba_osemek <= liczba_jedenastek) {
cout << liczba_osemek;
return 0;
}
int a = 0;
if (liczba_osemek > liczba_jedenastek) {
a = liczba_jedenastek % liczba_osemek;
cout << a;
return 0;
} else {
cout << liczba_jedenastek;
return 0;
}
}
|
#include <bits/stdc++.h>
using namespace std;
string ntos(long long int n) {
ostringstream str1;
str1 << n;
return str1.str();
}
long long int ston(string s) {
long long int x;
stringstream str1(s);
str1 >> x;
return x;
}
char a1[3] = {'R', 'G', 'B'};
char b1[3] = {'G', 'B', 'R'};
char c1[3] = {'B', 'R', 'G'};
bool bal(pair<long long int, long long int> a,
pair<long long int, long long int> b) {
return b.second > a.second;
}
int main() {
int n;
string s;
cin >> n >> s;
int e = 0;
int h = (s.size()) / 11;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '8') e++;
}
cout << min(e, h);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s;
cin >> s;
int x = count(s.begin(), s.end(), '8');
cout << min(x, n / 11);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
string str;
scanf("%d", &n);
cin >> str;
int c = 0;
for (int i = 0; i < n; i++) {
if (str[i] == '8') {
c++;
}
}
int ans = min(n / 11, c);
printf("%d\n", ans);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
static char s[1000];
int ns;
scanf("%d%s", &ns, s);
int ans = 0;
for (int i = 0; i < ns; ++i) {
if (s[i] == '8') ++ans;
}
ans = min(ans, ns / 11);
printf("%d\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
long long n;
cin >> n;
char s;
long long cnt = 0;
while (cin >> s) {
cnt += s == '8';
}
long long ans = 0;
for (long long i = 0; i <= cnt; ++i) {
if (min(i, (n - i) / 10) > ans) ans = min(i, (n - i) / 10);
}
cout << ans;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
string Str1, StrTmp;
int n;
while (cin >> n >> Str1) {
int n8 = 0, nx = 0, n_pair = 0, ans = 0;
for (int i = 0; i < n; i++) {
if (Str1[i] == '8') ++n8;
}
n_pair = n / 11;
if (n_pair <= n8)
ans = n_pair;
else if (n8 <= n_pair && n8 != 0)
ans = n8;
if (n8 == 0) {
ans = 0;
}
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
const long long INF = 2e18;
const long long N = 1e6 + 1;
const long long mod = 1e9 + 1;
const long double eps = 1E-7;
using namespace std;
void solve() {
int n;
string s;
cin >> n;
cin >> s;
sort(s.begin(), s.end());
int x = 0;
for (int i = n - 1; i >= 0; --i) {
if (s[i] == '8') x++;
if (x * 11 > n) {
x--;
break;
}
}
cout << x << endl;
}
bool mtest = false;
int main() {
ios_base::sync_with_stdio(0);
int TE = 1;
if (mtest) cin >> TE;
while (TE--) solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, c = 0, res;
string st;
cin >> n >> st;
for (int i = 0; i < st.size(); i++) {
if (st[i] == '8') c++;
}
res = n / 11;
res = min(res, c);
cout << res << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, cnt = 0;
char *s = (char *)malloc(n + 1);
scanf("%d%s", &n, s);
for (int i = 0; i < n; i++) {
if (s[i] == '8') {
cnt++;
}
}
printf("%d\n", min(n / 11, cnt));
}
|
#include <bits/stdc++.h>
int main() {
int n;
std::cin >> n;
int counter = 0;
if (n < 11) {
std::cout << 0;
return 0;
} else if (n > 100) {
return 0;
}
char *buf = new char;
bool validNumber = false;
std::cin >> buf;
for (int x = 0; x < n; x++) {
if (buf[x] == '8') {
counter++;
validNumber = true;
}
}
if (!validNumber) {
std::cout << 0;
return 0;
}
double d;
d = n / 11;
d = trunc(d);
if (d > counter) {
std::cout << counter;
} else {
std::cout << d;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void NITRO() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
const int N = 1e+4 * 5 + 55;
const int MOD = 1e+9 + 7;
const long long INF = 1e+18;
void SOLVE() {
int n, ei = 0;
string word;
cin >> n >> word;
for (int i = 0; i < n; i++) {
if (word[i] == '8') ei++;
}
cout << min(n / 11, ei);
}
int main() {
NITRO();
SOLVE();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 123;
const long double EPS = 1e-9;
const int MX = 1e9 + 1;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 1e5 + 123;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
int main() {
int n, ans = 0, a = 0, b = 0;
cin >> n;
string s;
cin >> s;
for (int i = 0; i < s.size(); ++i) {
if (s[i] == '8') {
a++;
}
b++;
}
ans = min(a, b / 11);
cout << ans;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
int phone_numbers = 0;
int eights = 0;
cin >> n;
string cards;
cin >> cards;
for (int i = 0; i < n; i++) {
if (cards[i] == '8') eights++;
}
for (int i = 0; i < eights; i++) {
if (n - 11 >= 0) phone_numbers++;
n = n - 11;
}
cout << phone_numbers;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int main() {
cin >> n;
cin >> s;
int ans = 0;
int k = 0;
for (int i = 0; i < s.size(); i++)
if (s[i] == '8') k++;
int res = n / 11;
ans = min(k, res);
cout << ans;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
int n, i, e = 0, t = 0, c = 0;
cin >> n >> s;
for (i = 0; i < n; i++)
if (s[i] == '8') e++;
c = n - e;
t = t + min(e, c / 10);
if (e - t <= 0) {
cout << t << endl;
return 0;
}
e = e - t;
c = c % 10;
if (e > 0 && c >= 10) {
t++;
c -= 10;
}
t = t + (e + c) / 11;
cout << t << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, i, cate, cate2;
char s;
int main() {
cin >> n;
for (i = 1; i <= n; i++) {
cin >> s;
if (s == '8') cate2++;
}
cout << min(n / 11, cate2);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, ans;
int main() {
scanf("%d", &n);
char ch = getchar();
while (ch == '\n' || ch == '\r' || !~ch) ch = getchar();
for (int i = 1; i <= n; i++) {
if (ch == '8') ans++;
ch = getchar();
}
printf("%d\n", min(n / 11, ans));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, cnt;
char s[200];
int main() {
scanf("%d%s", &n, s);
for (int i = 0; i < n; i++)
if (s[i] == '8') cnt++;
int ans = min(cnt, n / 11);
printf("%d\n", ans);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
string number;
int c = 0;
scanf("%d", &n);
cin >> number;
for (int i = 0; i < number.size(); i++) {
if (number[i] == '8') ++c;
}
printf("%d\n", min(c, (n / 11)));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string str;
int n;
scanf("%d", &n);
cin >> str;
if (n >= 11) {
int num = count(str.begin(), str.end(), '8');
if (n / 11 <= num) {
printf("%d\n", n / 11);
} else {
printf("%d\n", num);
}
} else {
printf("%d\n", 0);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int length;
string S;
cin >> length >> S;
int no_of_8 = 0;
for (int i = 0; i < length; i++) no_of_8 += (S[i] == '8');
cout << (no_of_8 < length / 11 ? no_of_8 : length / 11) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s;
cin >> s;
int cnt = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '8') {
cnt++;
}
}
cout << min(cnt, n / 11);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
string s;
cin >> n >> s;
int c = 0;
for (int i = 0; i < n; ++i) {
if (s[i] == '8') c++;
}
int res = n / 11;
res = min(res, c);
cout << res;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int freq[10];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
string x;
cin >> n >> x;
for (int i = 0; i < n; i++) {
freq[x[i] - '0']++;
}
cout << min(n / 11, freq[8]) << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
string s;
cin >> n;
cin >> s;
int count = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '8') {
count++;
}
}
int a = n / 11;
if (count >= a) {
cout << a;
} else {
cout << count;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int const MOD = 1000000007;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
long long int n;
cin >> n;
string str;
cin >> str;
long long int eightcount = 0;
for (int i = 0; i < str.size(); i++) {
if (str[i] == '8') {
eightcount++;
}
}
cout << min(eightcount, n / 11) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 10;
int n, cnt[M];
string s;
int main() {
cin >> n >> s;
for (int i = 0; i < n; i++) cnt[s[i]]++;
cout << min(cnt['8'], n / 11) << endl;
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.