text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; const int inf = 1e9; bool block[maxn]; vector<int> go(maxn); inline int get(int x, int n, int m) { int it = 0, pos = 0; if (m && block[0]) return inf; int res = 1; while (pos + x < n) { res++; int start = pos; pos += x; pos = go[pos]; if (pos == start) return inf; } return res; } int main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); int n, m, k; scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < m; ++i) { int pos; scanf("%d", &pos); block[pos] = 1; } for (int i = 0; i <= n; ++i) { if (block[i]) { if (block[i - 1]) go[i] = go[i - 1]; else go[i] = i - 1; } else go[i] = i; } long long ans = -1; for (int i = 1; i <= k; ++i) { int cost; scanf("%d", &cost); int cnt = get(i, n, m); if (cnt != inf) { if (ans == -1) ans = 1LL * cnt * cost; else ans = min(ans, 1LL * cnt * cost); } } printf("%I64d", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, k, a[1000010], st[1000010], cnt, mx; int main() { scanf("%d%d%d", &n, &m, &k); n++; int tem = 0; for (int i = 1; i <= n; i++) st[i] = i; for (int i = 1; i <= m; i++) { scanf("%d", &tem); tem++; if (tem == 1) { puts("-1"); return 0; } st[tem] = -1; if (st[tem] == st[tem - 1]) cnt++; else cnt = 1; if (mx < cnt) mx = cnt; } for (int i = 2; i <= n; i++) st[i] = max(st[i], st[i - 1]); for (int i = 1; i <= k; i++) scanf("%d", a + i); if (mx >= k) { puts("-1"); return 0; } if (st[1] == -1) { puts("-1"); return 0; } long long ans = 1000000000000000000ll; for (int i = mx + 1; i <= k; i++) { int cnt = 1, tot = 0; while (cnt < n) { cnt = st[cnt] + i; tot++; } ans = min(ans, (long long)tot * a[i]); } printf("%lld", ans); }
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const long long INFL = 0x3f3f3f3f3f3f3f3fLL; int n, m, q, aSize; int a[N], b[N]; int main() { scanf("%d%d%d", &n, &m, &q); int p = 0; aSize = 0; for (int i = 1; i <= m; ++i) { int v; scanf("%d", &v); for (int j = p; j <= v - 1; ++j) a[++aSize] = j; p = v + 1; } while (p <= n) a[++aSize] = p++; for (int i = 1; i <= q; ++i) scanf("%d", &b[i]); for (int i = q - 1; i >= 1; --i) b[i] = min(b[i], b[i + 1]); int maxDist = 0; for (int i = 2; i <= aSize; ++i) maxDist = max(maxDist, a[i] - a[i - 1]); if (a[1] != 0 || maxDist > q) { puts("-1"); return 0; } long long ans = INFL; for (int i = maxDist; i <= q; ++i) { int d = 0; for (int j = 0; j < n;) { int p = upper_bound(a + 1, a + aSize + 1, j + i) - a - 1; j = a[p]; ++d; } ans = min(ans, (long long)d * b[i]); } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; bool isrange(int second, int first, int n, int m) { if (0 <= second && second < n && 0 <= first && first < m) return true; return false; } int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1}, ddy[8] = {1, 0, -1, 0, 1, 1, -1, -1}, ddx[8] = {0, 1, 0, -1, 1, -1, 1, -1}; long long int val[1111111], dp[1111111]; int main(void) { int n, m, k, diff = 0, ll = -1, vv = 0; long long int ans = 1e18; scanf("%d%d%d", &n, &m, &k); for (int e = 0; e < m; e++) { int s; scanf("%d", &s); dp[s] = 1; if (ll == -1) { ll = s; vv = 1; diff = max(diff, vv); } else { if (ll + 1 == s) { vv++; } else vv = 1; ll = s; diff = max(diff, vv); } } for (int e = 1; e <= k; e++) scanf("%lld", &val[e]); for (int e = 1; e < n; e++) { if (dp[e]) dp[e] = dp[e - 1]; else dp[e] = e; } if (dp[0] || diff + 1 > k) { printf("-1"); } else { for (int e = diff + 1; e <= k; e++) { long long int tot = 0; for (int p = 0;;) { p += e; tot++; if (p >= n) break; p = dp[p]; } ans = min(ans, val[e] * tot); } printf("%lld", ans); } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10, mod = 1e9 + 7; int cost; int n, m, k; int best[N]; int cal(int x) { int co = 1; int cu = x; while (cu < n) { auto it = best[cu]; if (it + x <= cu) return -1; co++; cu = it + x; } return co; } bool notgood[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; cin >> x; notgood[x] = 1; } for (int i = 1; i < n; i++) { if (notgood[i]) best[i] = best[i - 1]; else best[i] = i; } if (notgood[0]) { cout << -1 << "\n"; return 0; } long long ans = -1; for (int i = 1; i <= k; i++) { cin >> cost; long long co = cal(i); if (co != -1) { if (ans == -1) ans = co * cost; else ans = min(ans, co * cost); } } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e5; long long int n; long long int ox[1000010]; long long int kh[1000010]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int n, m, k; cin >> n >> m >> k; long long int s[m + 1]; long long int a[k + 1]; for (int i = 1; i <= m; i++) { cin >> s[i]; } for (int i = 1; i <= k; i++) { cin >> a[i]; } for (int i = 1; i <= m; i++) { ox[s[i]] = 1; } if (ox[0]) { cout << -1 << '\n'; return 0; } sort(s + 1, s + m + 1); long long int cons = 0, temp = 1; for (int i = 2; i <= m; i++) { if (s[i] != s[i - 1] + 1) { cons = max(temp, cons); temp = 1; } else { temp++; } } cons = max(cons, temp); if (m == 0) { cons = 0; } int kh1 = 0; for (int i = 0; i <= n; i++) { if (ox[i] == 1) { kh[i] = kh1; } else { kh1 = i; kh[i] = i; } } long long int ans = 1e18; for (int i = 1; i <= k; i++) { if (i <= cons) { continue; } long long int temp = 0; for (int j = 0; j < n; j += (i)) { if (ox[j] == 0) { temp++; } else { j = kh[j]; temp++; } } ans = min(a[i] * temp, ans); } if (ans == 1e18) { cout << -1 << '\n'; return 0; } else { cout << ans << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class T> using V = vector<T>; template <class T, class U> using P = pair<T, U>; using vll = V<ll>; using vvll = V<vll>; template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } constexpr ll MOD = 1000000007; constexpr ll HIGHINF = (ll)1e18; constexpr int INF = 1e9; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; V<int> block(n + 1, 0), a(k); for (int i = 0; i < m; i++) { int s; cin >> s; block[s] = 1; } for (int i = 0; i < k; i++) cin >> a[i]; V<int> goback(n + 1, -1); if (block[0] == 0) goback[0] = 0; for (int i = 1; i <= n; i++) { if (block[i] == 0) goback[i] = i; else goback[i] = goback[i - 1]; } if (goback[0] == -1) { cout << -1 << '\n'; return 0; } ll ans = HIGHINF; for (int i = 1; i <= k; i++) { ll cost = a[i - 1]; int cur = 0, step = 0; while (cur < n) { int nxt = goback[min(cur + i, n)]; if (nxt <= cur) { step = INF; break; } step++; cur = nxt; } if (step == INF) continue; chmin(ans, ll(step) * cost); } if (ans == HIGHINF) ans = -1; cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; long long a[2000011], n, m, k; bool b[2000011]; int s[2000011]; long long process(long long t) { long long c = a[t], ret = 0; if (s[1]) return (1LL << 60); ret = c; int cl = 2, cr = t + 1; while (cr < n + 1) { if (s[cr] - s[cr - 1] == 0) { ret += c; cr = cr + t + 1; cl = cr - t; cr--; } else if (s[cr] - s[cl - 1] == cr - cl + 1) { return (1LL << 60); } else { int lo = cl, hi = cr; while (lo + 1 < hi) { int mid = (lo + hi) / 2; if (s[cr] - s[mid - 1] != cr - mid + 1) lo = mid; else hi = mid; } cr = lo + t + 1; cl = cr - t; ret += c; cr--; } } return ret; } int main() { scanf("%lld %lld %lld", &n, &m, &k); for (int i = 1; i <= m; i++) { int x; scanf("%d", &x); b[x + 1] = true; } for (int i = 1; i <= 2 * n; i++) { s[i] = s[i - 1] + b[i]; } for (int i = 1; i <= k; i++) scanf("%lld", &a[i]); long long res = (1LL << 60); for (int i = 1; i <= k; i++) { res = min(res, process(i)); } if (res == (1LL << 60)) puts("-1"); else printf("%lld\n", res); return 0; }
#include <bits/stdc++.h> using namespace std; const long long INF(0x3f3f3f3f3f3f3f3fll); const long long inf(0x3f3f3f3f); template <typename T> void read(T &res) { bool flag = false; char ch; while (!isdigit(ch = getchar())) (ch == '-') && (flag = true); for (res = ch - 48; isdigit(ch = getchar()); res = (res << 1) + (res << 3) + ch - 48) ; flag && (res = -res); } template <typename T> void Out(T x) { if (x < 0) putchar('-'), x = -x; if (x > 9) Out(x / 10); putchar(x % 10 + '0'); } long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return a * b / gcd(a, b); } long long pow_mod(long long x, long long n, long long mod) { long long res = 1; while (n) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } long long fact_pow(long long n, long long p) { long long res = 0; while (n) { n /= p; res += n; } return res; } long long mult(long long a, long long b, long long p) { a %= p; b %= p; long long r = 0, v = a; while (b) { if (b & 1) { r += v; if (r > p) r -= p; } v <<= 1; if (v > p) v -= p; b >>= 1; } return r; } long long quick_pow(long long a, long long b, long long p) { long long r = 1, v = a % p; while (b) { if (b & 1) r = mult(r, v, p); v = mult(v, v, p); b >>= 1; } return r; } bool CH(long long a, long long n, long long x, long long t) { long long r = quick_pow(a, x, n); long long z = r; for (long long i = 1; i <= t; i++) { r = mult(r, r, n); if (r == 1 && z != 1 && z != n - 1) return true; z = r; } return r != 1; } bool Miller_Rabin(long long n) { if (n < 2) return false; if (n == 2) return true; if (!(n & 1)) return false; long long x = n - 1, t = 0; while (!(x & 1)) { x >>= 1; t++; } srand(time(NULL)); long long o = 8; for (long long i = 0; i < o; i++) { long long a = rand() % (n - 1) + 1; if (CH(a, n, x, t)) return false; } return true; } void exgcd(long long a, long long b, long long &x, long long &y) { if (!b) { x = 1, y = 0; return; } exgcd(b, a % b, x, y); long long t = x; x = y, y = t - (a / b) * y; } long long inv(long long a, long long b) { long long x, y; return exgcd(a, b, x, y), (x % b + b) % b; } long long crt(long long x, long long p, long long mod) { return inv(p / mod, mod) * (p / mod) * x; } long long fac(long long x, long long a, long long b) { if (!x) return 1; long long ans = 1; for (long long i = 1; i <= b; i++) if (i % a) ans *= i, ans %= b; ans = pow_mod(ans, x / b, b); for (long long i = 1; i <= x % b; i++) if (i % a) ans *= i, ans %= b; return ans * fac(x / a, a, b) % b; } long long C(long long n, long long m, long long a, long long b) { long long N = fac(n, a, b), M = fac(m, a, b), Z = fac(n - m, a, b), sum = 0, i; for (i = n; i; i = i / a) sum += i / a; for (i = m; i; i = i / a) sum -= i / a; for (i = n - m; i; i = i / a) sum -= i / a; return N * pow_mod(a, sum, b) % b * inv(M, b) % b * inv(Z, b) % b; } long long exlucas(long long n, long long m, long long p) { long long t = p, ans = 0, i; for (i = 2; i * i <= p; i++) { long long k = 1; while (t % i == 0) { k *= i, t /= i; } ans += crt(C(n, m, i, k), p, k), ans %= p; } if (t > 1) ans += crt(C(n, m, t, t), p, t), ans %= p; return ans % p; } const long long N = 1e6 + 10; long long a[N], vis[N], pre[N]; set<long long> s; signed main() { long long n, m, k; read(n), read(m), read(k); for (long long i = 1; i <= m; i++) { long long x; cin >> x; vis[x] = 1; } for (long long i = 1; i <= k; i++) read(a[i]); if (vis[0]) return puts("-1"), 0; for (long long i = 0; i <= n - 1; i++) if (!vis[i]) s.insert(-i); long long ans = INF; for (long long i = 0; i <= n - 1; i++) { auto it = s.lower_bound(-i); if (it == s.end()) pre[i] = INF; else pre[i] = -*it; } for (long long i = 1; i <= k; i++) { long long cnt = 0, flag = 0, far = 0; for (long long j = 0; j <= n - 1; j += i) { if (!vis[j]) { cnt++; continue; } if (pre[j] == INF || pre[j] == far) { flag = 1; break; } cnt++, far = pre[j], j = pre[j]; } if (flag) continue; ans = min(ans, cnt * a[i]); } if (ans == INF) puts("-1"); else Out(ans); return 0; }
#include <bits/stdc++.h> using namespace std; int mark[1000005], l[1000005]; long long cost[1000005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, k; cin >> n >> m >> k; for (int i = 1; i <= m; i++) { int temp; cin >> temp; mark[temp] = 1; } for (int i = 1; i <= k; i++) cin >> cost[i]; if (mark[0] == 1) { cout << "-1"; return 0; } int last = 0, dis = 0; for (int i = 1; i <= n - 1; i++) { if (!mark[i]) { dis = max(dis, i - last); last = i; } else l[i] = last; } dis = max(dis, n - last); if (dis > k) { cout << "-1\n"; return 0; } long long minn = 2000000000000000005; int ind = 1; for (int i = dis; i <= k; i++) { long long cnt = 1; for (int j = i; j < n;) { if (mark[j]) { j = l[j]; } else { cnt++; j = j + i; } } minn = min(cost[i] * cnt, minn); } cout << minn << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int b[1100000], a[1100000], pre[1100000]; int main() { int n, m, k, i, j, s, cnt, len = 0, max = 0; long long ans = 0; scanf("%d%d%d", &n, &m, &k); for (i = 1; i <= m; ++i) { scanf("%d", &s); b[s] = 1; } b[n] = 1; for (i = 1; i < n; ++i) if (b[i]) pre[i] = pre[i - 1]; else pre[i] = i; for (i = 1; i < n; ++i) { if (b[i]) ++len; else len = 0; if (len > max) max = len; } for (i = 1; i <= k; ++i) scanf("%d", &a[i]); if (max == 0) max = 1; else ++max; for (i = max; i <= k; ++i) { cnt = 0; j = 0; if (b[j]) continue; while (j < n) { ++cnt; if (!b[j]) j = j + i; else j = pre[j] + i; } if (ans == 0) ans = (long long)cnt * a[i]; else if ((long long)cnt * a[i] < ans) ans = (long long)cnt * a[i]; } if (ans > 0) printf("%I64d", ans); else printf("-1"); return 0; }
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const int INF = 0x3f3f3f3f; const int maxn = 1e6 + 5; bool b[maxn]; int a[maxn]; int main() { ios::sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; memset(b, true, sizeof(b)); for (int i = 0; i < m; i++) { int x; cin >> x; if (x == 0) { cout << -1; return 0; } b[x] = false; if (b[x - 1]) a[x] = x - 1; else a[x] = a[x - 1]; } long long ans = 1e18; for (int i = 1; i <= k; i++) { int x; cin >> x; int j = 0; long long res = 0; int f = 0; while (j < n) { int k = j; res += x; j += i; if (j < n && !b[j]) { j = a[j]; if (j == k) { f = 1; break; } } } if (f == 0) ans = min(ans, res); } if (ans < 1e18) cout << ans; else cout << -1; return 0; }
#include <bits/stdc++.h> using namespace std; string to_string(string s) { return '"' + s + '"'; } string to_string(const char* s) { return to_string((string)s); } 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 first = true; string res = "{"; for (const auto& x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; } void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); } const long double eps = 1e-12; const int N = 1e6 + 9; int cnt, mx, a[N], b[N]; bool bloc[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m, k; cin >> n >> m >> k; for (int i = 0; i < m; i++) { cin >> b[i]; bloc[b[i]] = 1; } for (int i = 1; i <= k; i++) { cin >> a[i]; } set<int> ss; for (int i = 0; i < n; i++) { if (bloc[i] == 1) cnt++; else { ss.insert(-i); mx = max(mx, cnt); cnt = 0; } } mx = max(mx, cnt); long long ans = 1e18; if (mx >= k || bloc[0]) return cout << "-1\n", 0; for (int i = mx + 1; i <= k; i++) { cnt = 0; for (int j = 0; j < n;) { if (bloc[j]) { j = -(*ss.upper_bound(-j)); } else { j += i; cnt++; } } ans = min(ans, 1ll * cnt * a[i]); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m >> k; vector<bool> blocked(n + 1, false); for (int i = 0; i < m; ++i) { int loc; scanf("%d", &loc); if (loc == 0) { cout << -1 << endl; return 0; } blocked[loc] = true; } vector<long long int> costs(k); for (int i = 0; i < k; ++i) { scanf("%lld", &costs[i]); } vector<int> coord(n + 1); coord[0] = 0; for (int i = 1; i <= n; ++i) { if (blocked[i]) { coord[i] = coord[i - 1]; } else { coord[i] = i; } } int now = 0; int cons = 0; for (int i = 0; i <= n; ++i) { if (blocked[i]) { ++now; if (now > cons) cons = now; } else { now = 0; } } if (cons >= k) { cout << -1 << endl; return 0; } long long int answer = (long long int)n * (long long int)10000000; for (int i = cons + 1; i <= k; ++i) { long long int count = 0; long long int here = 0; while (true) { count += costs[i - 1]; if (here + i >= n) { break; } else { here = coord[here + i]; } } if (count < answer) answer = count; } cout << answer << endl; }
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long double pi = 3.14159265358979323846264338327950288; int second[1000001], near[1000001]; int main() { int n, k, m; cin >> n >> m >> k; int a[k]; for (int i = 0; i < m; i++) { int tmp; scanf("%d", &tmp); second[tmp] = 1; } for (int i = 0; i < k; i++) scanf("%d", &a[i]); int cnt = 0, mx = 0; for (int i = 0; i < n; i++) { if (second[i] == 1) cnt++, near[i] = near[i - 1]; else cnt = 0, near[i] = i; mx = max(mx, cnt); } if (mx >= k || second[0] == 1) { cout << -1 << endl; } else { long long ans = 1e18; for (int i = mx + 1; i <= k; i++) { long long tmp = 0; for (int j = 0; j < n; j += i) { int cmt = 0; if (near[j] <= j - i) { tmp = 1e18; break; } j = near[j]; tmp += (long long)a[i - 1]; } ans = min(tmp, ans); } if (ans == 1e18) cout << -1 << endl; else cout << ans << endl; } }
#include <bits/stdc++.h> struct compare { bool operator()(const int& l, const int& r) { return l > r; } }; using namespace std; priority_queue<int, vector<int>, compare> pq; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, k; cin >> n >> m >> k; int s[m]; for (int i = 0; i < m; ++i) cin >> s[i]; long long a[k + 1]; for (int i = 1; i < k + 1; ++i) cin >> a[i]; int c = 0; vector<int> u; for (int i = 0; i < n; i++) { if (c == m) u.push_back(i); else if (i == s[c]) c++; else u.push_back(i); } if (u.size() == 0) { cout << -1; return 0; } else if (u[0]) { cout << -1; return 0; } long long mi = 1e14; for (int kk = 1; kk <= k; kk++) { int cnt = 0; int f = 0; int i = 0; while (i < n) { int ind = upper_bound(u.begin(), u.end(), i + 1) - u.begin(); ind = max(ind, 0); if (ind >= u.size()) ind = u.size() - 1; while (ind > 0 && u[ind] > i) ind--; if (u[ind] > i) { f = 1; break; } else if (u[ind] <= i - kk) { f = 1; break; } else { i = u[ind] + kk; cnt++; } } if (!f) { mi = min(mi, cnt * a[kk]); } } if (mi >= (long long)1e14) cout << -1 << "\n"; else cout << mi << "\n"; }
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f, mod = 1000000007; const double pi = 3.1415926535897932, eps = 1e-6; int n, m, k, p[1000005], lst[1000005]; bool a[1000005]; long long ans = 0x3f3f3f3f3f3f3f3f; int solve(int x) { int las = -1, p = 0, ans = 0; while (p < n) { las = p; p = lst[p] + x; ans++; if (p <= las) return -1; } return ans; } int main() { ios::sync_with_stdio(false); cin >> n >> m >> k; for (int(i) = (1); (i) <= (m); (i)++) { int tmp; cin >> tmp; a[tmp] = 1; } for (int(i) = (1); (i) <= (k); (i)++) cin >> p[i]; if (a[0]) { cout << "-1"; return 0; } for (int(i) = (0); (i) < (n); (i)++) if (a[i]) lst[i] = lst[i - 1]; else lst[i] = i; for (int(i) = (1); (i) <= (k); (i)++) { int cur = solve(i); if (cur != -1) ans = min(ans, (long long)cur * p[i]); } if (ans > 1e18) cout << "-1"; else cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1000100; namespace Solver { int64_t n, m, maxPow, cost[N], last[N]; void solve() { cin >> n >> m >> maxPow; for (int i = 1, x; i <= m; ++i) { cin >> x; last[x] = 1; } if (last[0] == 1) { cout << -1 << "\n"; exit(0); } for (int i = 1; i <= maxPow; ++i) { cin >> cost[i]; } int64_t leastPow = 1; for (int i = 1; i < n; ++i) { if (last[i] == 1) { last[i] = last[i - 1]; } else { last[i] = i; } leastPow = max(leastPow, (int64_t)(i - last[i] + 1)); } if (leastPow > maxPow) { cout << -1 << "\n"; exit(0); } int64_t ans = n * 10000000LL; for (int d = leastPow; d <= maxPow; ++d) { int pos = 0; int64_t res = 0; do { res += cost[d]; pos += d; if (pos < n && last[pos] <= pos - d) { res = n * 10000000LL + 1; break; } if (pos < n) pos = last[pos]; } while (pos < n); if (ans > res) { ans = res; } } if (ans <= n * 1000000LL) { cout << ans << "\n"; exit(0); } else { cout << -1 << "\n"; exit(0); } } } // namespace Solver int main() { ios::sync_with_stdio(0); Solver::solve(); return 0; }
#include <bits/stdc++.h> inline bool IsDigit(char c) { return (c >= '0' && c <= '9'); } inline int Read() { int sum = 0, f = 1; char c = 0; while (!IsDigit(c)) { if (c == '-') f = -1; c = getchar(); } while (IsDigit(c)) { sum = (sum << 3) + (sum << 1) + c - '0'; c = getchar(); } return sum * f; } const int NMAX = 1e6 + 10; int n, m, a[NMAX], mp[NMAX], t, k, f[NMAX], ma = 0; int main() { n = Read(), m = Read(), k = Read(); for (int i = 1; i <= m; i++) { t = Read(); mp[t] = -1; } for (int i = 1; i <= k; i++) a[i] = Read(); if (mp[0] == -1) { printf("-1"); return 0; } for (int i = 0; i < n; i++) { if (mp[i] == -1) { f[i] = f[i - 1]; if (i - f[i] > ma) ma = i - f[i]; } else f[i] = i; } long long ans = 0x3f3f3f3f3f3f3f3f, tot = 0; for (int i = ma + 1; i <= k; i++) { int p = 0; tot = 0; while (p < n) { p = f[p] + i; tot++; } if (tot * a[i] < ans) ans = tot * a[i]; } if (ans == 0x3f3f3f3f3f3f3f3f) { printf("-1"); } else { printf("%lld", ans); } return 0; }
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") using namespace std; const int N = 2e6 + 7; const long long INF = 1e18 + 7; long long res[N]; int us[N], cst[N], pos[N]; int n, m, k, mx; long long ans = INF; int main() { scanf("%d%d%d", &n, &m, &k); int a; for (int i = 1; i <= m; i++) { scanf("%d", &a); us[a] = us[max(0, a - 1)] + 1; mx = max(mx, us[a]); } for (int i = 1; i <= k; i++) scanf("%d", &cst[i]); if (us[0]) { puts("-1"); return 0; } for (int i = mx + 1; i <= k; i++) { while (pos[i] < n) { pos[i] += i - us[pos[i] + i]; res[i] += cst[i]; } ans = min(ans, res[i]); } if (ans == INF) puts("-1"); else cout << ans; }
#include <bits/stdc++.h> using namespace std; const int MX = 1e6 + 5; const int mod = 1e9 + 7; const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3fLL; int n, m, k; int s[MX], a[MX]; int b[MX]; int main() { while (cin >> n >> m >> k) { for (int i = 1; i <= m; i++) scanf("%d", &s[i]), b[s[i]] = 1; for (int i = 1; i <= k; i++) scanf("%d", &a[i]); m = 0; for (int i = 0; i <= n; i++) if (!b[i]) s[++m] = i; if (s[1] > 0) { printf("-1\n"); continue; } long long ans = INF; for (int i = 1; i <= k; i++) { int x = i, cnt = 0; int index = 1, flag = 1; while (index <= m) { if (s[index] + x >= n) { cnt++; break; } int p = upper_bound(s + 1, s + m + 1, s[index] + x) - s - 1; cnt++; if (p == index) { flag = 0; break; } index = p; } if (flag) ans = min(ans, (long long)cnt * a[i]); } cout << (ans == INF ? -1 : ans) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; using INT = long long; using pii = pair<int, int>; int vst[1001000], cst[1001000], nxt[1001000]; int main() { ios_base ::sync_with_stdio(0); cin.tie(0); int n, m, k; cin >> n >> m >> k; for (int i = 1; i <= m; i++) { int pos; cin >> pos; vst[pos] = 1; } for (int i = 1; i <= k; i++) cin >> cst[i]; nxt[n] = n + 1; for (int i = n; i >= 0; i--) { nxt[i] = nxt[i + 1]; if (vst[i] == 0) nxt[i] = i; } INT ans = 0x3f3f3f3f3f3f3f3f; for (int len = 1; len <= k; len++) { INT tmp = 0; int pos = n; int flag = 1; while (1) { if (nxt[max(0, pos - len)] >= pos) { flag = 0; break; } pos = nxt[max(0, pos - len)]; tmp += cst[len]; if (pos == 0) break; } if (flag) ans = min(ans, tmp); } if (ans > 1000000000000000000ll) cout << "-1" << endl; else cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int x[1000009], c[1000009], last[1000009]; int main() { int n, a, m, k, i, j, s = 0, smax = 0, cnt, l; scanf("%d %d %d", &n, &m, &k); for (i = 0; i < m; i++) { scanf("%d", &a); x[a] = 1; if (i != 0 && x[a - 1] == 1) { s++; smax = max(s, smax); } else s = 1; } smax = max(s, smax); for (i = 1; i <= k; i++) scanf("%d", &c[i]); if (smax + 1 > k || x[0] == 1) { printf("-1"); return 0; } for (i = 0; i <= n; i++) { if (x[i] == 0) last[i] = i; else last[i] = last[i - 1]; } long long ans, ansmin = -1; for (i = smax + 1; i <= k; i++) { l = 0; cnt = 0; while (l < n) { cnt++; if (l + i >= n) break; l = last[l + i]; } ans = (long long)cnt * (long long)c[i]; if (ansmin == -1) ansmin = ans; else ansmin = min(ansmin, ans); } printf("%lld", ansmin); return 0; }
#include <bits/stdc++.h> using namespace std; bool B[1000010] = {0}; int pre[1000010]; long long cost[1000010] = {0}; int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long n, m, k, a; cin >> n >> m >> k; for (int i = 0; i < m; ++i) cin >> a, B[a] = 1; for (int i = 0; i < k; ++i) cin >> a, cost[i + 1] = a; if (B[0] == 1) return cout << "-1\n", 0; for (int i = 0; i < n; ++i) { int &a = pre[i]; if (not B[i]) a = i; else if (i) a = pre[i - 1]; else a = -1; } long long ans = 1ll << 60; for (int l = 1; l <= k; ++l) { bool fail = 0; long long cnt = 0; for (int i = 0; not fail and i < n;) { if (B[i]) { if (i - pre[i] >= l) fail = 1; else i = pre[i] + l, cnt += 1; } else { i = pre[i] + l, ++cnt; } } if (not fail) ans = min(ans, cnt * cost[l]); } if (ans == 1ll << 60) cout << "-1\n"; else cout << ans << '\n'; }
#include <bits/stdc++.h> using namespace std; int N, M, K; bool tkn[1000005]; int lst[1000005]; int main() { cin.sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> M >> K; for (int i = 1; i <= M; i++) { int n; cin >> n; tkn[n] = 1; } if (tkn[0]) { cout << -1 << endl; return 0; } for (int i = 1; i <= N; i++) { if (tkn[i]) { lst[i] = lst[i - 1]; } else { lst[i] = i; } } long long ans = LLONG_MAX; for (int k = 1; k <= K; k++) { long long c; cin >> c; long long v = c; int crnt = k; while (crnt < N) { if (crnt - lst[crnt] >= k) { v = LLONG_MAX; break; } crnt = lst[crnt]; v += c; crnt += k; } ans = min(v, ans); } if (ans == LLONG_MAX) { ans = -1; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; const long long md = 1e9 + 7; inline void add(long long &a, long long b) { a += b; if (a >= md) a -= md; } inline void sub(long long &a, long long b) { a -= b; if (a < 0) a += md; } inline long long mul(long long a, long long b) { return (long long)((long long)a * b % md); } inline long long power(long long a, long long b) { long long res = 1; while (b > 0) { if (b & 1) { res = mul(res, a); } a = mul(a, a); b >>= 1ll; } return res % md; } inline long long inv(long long a) { a %= md; if (a < 0) a += md; long long b = md, u = 0, v = 1; while (a) { int t = b / a; b -= t * a; swap(a, b); u -= t * v; swap(u, v); } assert(b == 1); if (u < 0) u += md; return u; } struct Event { Event(long long t, long long i, long long ty) : time(t), idx(i), type(ty) {} long long time, idx, type; bool operator<(const Event &rhs) { if (time == rhs.time) return type > rhs.type; return time < rhs.time; } }; const long long INF = 1e18; long long get(long long k, vector<long long> &rec) { long long r = 0, i = -1; long long n = rec.size(); long long ans = 0; while (r < n) { if (rec[r] <= i) return INF; i = rec[r]; r = rec[r] + k; ans++; } return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n, m, k; cin >> n >> m >> k; vector<long long> pos(n, 1); vector<long long> rec(n, -1); for (long long i = 0; i < m; i++) { long long x; cin >> x; pos[x] = 0; } for (long long i = 0; i < n; i++) { if (pos[i]) rec[i] = i; else if (i) rec[i] = rec[i - 1]; else rec[i] = -1; } vector<long long> c(k + 1); for (long long i = 1; i < k + 1; i++) cin >> c[i]; long long ans = INF; for (long long i = 1; i < k + 1; i++) { long long x = get(i, rec); if (x != INF) ans = min(ans, c[i] * x); } ans = ans == INF ? -1 : ans; cout << ans; }
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 7; int n, m, k, s[maxn]; bool vis[maxn]; long long a[maxn]; int main() { while (~scanf("%d%d%d", &n, &m, &k)) { memset(vis, 0, sizeof(vis)); memset(s, 0, sizeof(s)); while (m--) { int x; scanf("%d", &x); vis[x] = true; } for (int i = 1; i <= k; i++) scanf("%lld", &a[i]); if (vis[0]) { printf("-1\n"); continue; } int len = 0; long long ans = 1e18; for (int i = 0; i <= n; i++) { if (vis[i]) s[i] = s[i - 1] + 1; else s[i] = 0; len = max(len, s[i]); } ans = 1e18; for (int i = len + 1; i <= k; i++) { long long cnt = 0; for (int j = 0; j < n; j += i) { if (vis[j]) j -= s[j]; cnt++; } ans = min(ans, a[i] * cnt); } if (ans >= 1e18) printf("-1\n"); else printf("%I64d\n", ans); } return 0; }
#include <bits/stdc++.h> using namespace std; long long n, m, k, s[1020001], pv[1020001], a[1020001], vs[1020001]; long long es(long long x) { return a[x] * (n / x + (n % x == 0 ? 0 : 1)); } long long cp(long long x) { long long c = 0, i = 0, res = 0; while (c < n) { c += x, res++; while (i < m && s[i] < c) i++; if (i < m && s[i] == c) c = pv[i]; (0); } (0); return res; } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m >> k; for (int i = 0; i < m; i++) cin >> s[i]; for (int i = 1; i <= k; i++) cin >> a[i]; if (m > 0 && s[0] == 0) { return cout << "-1\n", 0; } long long lg = m > 0 ? 1 : 0; pv[0] = s[0] - 1; for (long long i = 1, gs = 1; i < m; i++) { if (s[i] == s[i - 1] + 1) gs++, lg = max(gs, lg); else gs = 1; pv[i] = s[i] - gs; } long long mk = lg + 1; if (mk > k) return cout << "-1\n", 0; for (long long i = mk; i <= k; i++) vs[i - mk] = i; sort(vs, vs + k - mk + 1, [&](long long x, long long y) { return es(x) < es(y); }); long long bs = 100000000000000000; for (long long i = 0; i < k - mk + 1; i++) { (0); if (bs < es(vs[i])) break; bs = min(bs, a[vs[i]] * cp(vs[i])); } cout << bs << '\n'; }
#include <bits/stdc++.h> using namespace std; int n,cnt[30]; char S[5]; int main() { scanf("%d",&n); for (int i=1;i<=n;i++) { scanf("%s",S); cnt[S[0]-65]++; } printf("AC x %d\n",cnt[0]); printf("WA x %d\n",cnt['W'-65]); printf("TLE x %d\n",cnt['T'-65]); printf("RE x %d\n",cnt['R'-65]); return 0; }
#include <iostream> #include <map> #define rep(i, n) for (int i = 0; i < n; ++i) using namespace std; int main() { int n; cin >> n; map<string, int> cnt; rep(i, n) { string s; cin >> s; cnt[s]++; } for (string s : {"AC", "WA", "TLE", "RE"}) { cout << s << " x " << cnt[s] << '\n'; } return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; map<string,int>judge; string qtr[4]={"AC","WA","TLE","RE"}; for(int i = 0 ; i < n ; i++ ){ string str; cin>>str; judge[str]++; } for(int i = 0;i<4;i++){ cout<<qtr[i]<<" x "<<judge[qtr[i]]<<endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main(){ int N; cin >> N; map<string, int> mp; rep(i, N) { string S; cin >> S; mp[S]++; } vector<string> L = {"AC", "WA", "TLE", "RE"}; rep(i, 4) cout << L[i] << " x " << mp[L[i]] << endl; }
#include <iostream> using namespace std; int main() { int N, C[4]{}; cin >> N; string S; while (cin >> S) ++(S == "AC" ? C[0] : S == "WA" ? C[1] : S == "TLE" ? C[2] : C[3]); cout << "AC x " << C[0] << endl << "WA x " << C[1] << endl << "TLE x " << C[2] << endl << "RE x " << C[3] << endl; }
#include <bits/stdc++.h> using namespace std; int main() { unordered_map<string,int> m; int n; string a; cin>>n; for(int i=0; i<n; ++i) { cin>>a; m[a]++; } printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",m["AC"], m["WA"], m["TLE"], m["RE"]); return 0; }
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; map<string,int> a; for(int i=0;i<n;i++) { string s; cin>>s; a[s]++; } for(string s:{"AC","WA","TLE","RE"}) cout<<s<<" x "<<a[s]<<endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; unordered_map<string,int>m; string a; while(n--){ cin>>a; m[a]++; } cout<<"AC x "<<m["AC"]<<endl; cout<<"WA x "<<m["WA"]<<endl; cout<<"TLE x "<<m["TLE"]<<endl; cout<<"RE x "<<m["RE"]<<endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; unordered_map<string , int> c; while(n--){ string s; cin>>s; c[s]++; } cout<<"AC x "<<c["AC"]<<endl<<"WA x "<<c["WA"]<<endl<<"TLE x "<<c["TLE"]<<endl<<"RE x "<<c["RE"]<<endl; }
#include<bits/stdc++.h> using namespace std; int main() { int t; cin>>t; int ac=0,wa=0,tle=0,re=0; while(t--){ string s; cin>>s; if(s=="AC") ++ac; else if(s=="WA") ++wa; else if(s=="TLE") ++tle; else ++re; } cout<<"AC x "<<ac<<"\n"<<"WA x "<<wa<<"\n"<<"TLE x "<<tle<<"\n"<<"RE x "<<re; return 0; }
#include<iostream> #include<map> using namespace std; int main(void){ int n; cin>>n; map<string, int>mp; string str; while(n--){ cin>>str; mp[str]++; } cout<<"AC"<<" x "<<mp["AC"]<<endl; cout<<"WA"<<" x "<<mp["WA"]<<endl; cout<<"TLE"<<" x "<<mp["TLE"]<<endl; cout<<"RE"<<" x "<<mp["RE"]<<endl; }
#include <iostream> using namespace std; int main() { int n; cin>>n; int a[26]={0}; string s; while(n--) { cin>>s; a[s[0]%65]++; } cout<<"AC x "<<a['A'%65]<<endl; cout<<"WA x "<<a['W'%65]<<endl; cout<<"TLE x "<<a['T'%65]<<endl; cout<<"RE x "<<a['R'%65]<<endl; return 0; }
#include<bits/stdc++.h> using namespace std; map<string,int> mapping; string s; int n; int main(){ cin>>n; while(n--){ cin>>s; mapping[s]++; } cout<<"AC x "<<mapping["AC"]<<'\n'; cout<<"WA x "<<mapping["WA"]<<'\n'; cout<<"TLE x "<<mapping["TLE"]<<'\n'; cout<<"RE x "<<mapping["RE"]<<'\n'; }
#include<bits/stdc++.h> using namespace std; int n,a,b,c,d,i; int main(){ cin>>n; string s; for(i=1;i<=n;i++){ cin>>s; if(s=="AC") a++; if(s=="WA") b++; if(s=="TLE") c++; if(s=="RE") d++; } cout<<"AC x "<<a<<endl; cout<<"WA x "<<b<<endl; cout<<"TLE x "<<c<<endl; cout<<"RE x "<<d; return 0; }
#include <iostream> #include <map> using namespace std; int main(){ int n; map<string,int> cnt; cin>>n; for(int i=0; i<n; i++){ string str; cin>>str; cnt[str]++; } printf("AC x %d\n",cnt["AC"]); printf("WA x %d\n",cnt["WA"]); printf("TLE x %d\n",cnt["TLE"]); printf("RE x %d\n",cnt["RE"]); }
#include<bits/stdc++.h> using namespace std; int main() { map<string,int>mp ; int n ; cin>>n ; while(n--) { string s ; cin>>s ; mp[s]++ ; } cout<<"AC x "<<mp["AC"]<<endl ; cout<<"WA x "<<mp["WA"]<<endl ; cout<<"TLE x "<<mp["TLE"]<<endl ; cout<<"RE x "<<mp["RE"]<<endl ; }
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; string s; int a=0,b=0,c=0,d=0; while(n--){ cin>>s; if(s=="AC") a++; else if(s=="WA") b++; else if(s=="TLE") c++; else d++; } cout<<"AC x "<<a<<endl; cout<<"WA x "<<b<<endl; cout<<"TLE x "<<c<<endl; cout<<"RE x "<<d; return 0; }
#include <bits/stdc++.h> using namespace std; int main(){ int n,a=0,b=0,c=0,d=0; cin >> n; while(n--){ string s; cin >> s; s=="AC"?a++:s=="WA"?b++:s=="TLE"?c++:s=="RE"?d++:0; } cout << "AC x " << a << "\nWA x " << b << "\nTLE x " << c << "\nRE x " << d; return 0; }
#include<bits/stdc++.h> using namespace std; int main() { int n; map<string, int> cnt; string s; cin>>n; while (n--) { cin>>s; cnt[s]++; } cout<<"AC x "<<cnt["AC"]<<endl; cout<<"WA x "<<cnt["WA"]<<endl; cout<<"TLE x "<<cnt["TLE"]<<endl; cout<<"RE x "<<cnt["RE"]<<endl; }
#include<bits/stdc++.h> using namespace std; int main() { int N; cin >> N; map<string, int> mp; for (int i = 0; i < N; i++) { string S; cin >> S; mp[S]++; } for (auto e: {"AC", "WA", "TLE", "RE"}) { cout << e << " x " << mp[e] << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<string, int> ma; string s; for(int i=0; i<n; i++) { cin >> s; ma[s]++; } for(auto ss: {"AC", "WA", "TLE", "RE"}) cout << ss << " x " << ma[ss] << endl; return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; map<string,int> S; for(int i=0;i<N;i++){ string A; cin >> A; S[A]++; } cout << "AC x " << S["AC"] << endl; cout << "WA x " << S["WA"] << endl; cout << "TLE x " << S["TLE"] << endl; cout << "RE x " << S["RE"] << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<string, int> mp; for (int i = 0; i < n; i++) { string s; cin >> s; ++mp[s]; } for (auto s : {"AC", "WA", "TLE", "RE"}) cout << s << " x " << mp[s] << "\n"; }
#include<bits/stdc++.h> using namespace std; int n; map<string,int>mp; int main(){ cin>>n; for(int i=0;i<n;i++){ string s;cin>>s; mp[s]++; } cout<<"AC x "<<mp["AC"]<<"\n"; cout<<"WA x "<<mp["WA"]<<"\n"; cout<<"TLE x "<<mp["TLE"]<<"\n"; cout<<"RE x "<<mp["RE"]<<"\n"; }
#include<bits/stdc++.h> using namespace std; int n; string s; map<string,int> m; int main(){ cin>>n; for(int i=0;i<n;i++) { cin>>s; m[s]++; } cout<<"AC"<<" x "<<m["AC"]<<endl; cout<<"WA"<<" x "<<m["WA"]<<endl; cout<<"TLE"<<" x "<<m["TLE"]<<endl; cout<<"RE"<<" x "<<m["RE"]; return 0; }
#include<iostream> #include<string> #include<map> using namespace std; int main() { int n; scanf("%d",&n); map<string, int> mp; while(n--){ string s; cin >> s; mp[s]++; } printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", mp["AC"], mp["WA"], mp["TLE"], mp["RE"]); return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ int n,m; map<string,int>s; string str; scanf("%d",&n); while(n--){ cin>>str; s[str]++; } printf("AC x %d\n",s["AC"]); printf("WA x %d\n",s["WA"]); printf("TLE x %d\n",s["TLE"]); printf("RE x %d\n",s["RE"]); return 0; }
#include<bits/stdc++.h> using namespace std; int main() { int n,a=0,b=0,c=0,d=0; cin>>n; string s; for(int i=0;i<n;i++) {cin>>s; if(s=="AC") a++; else if(s=="WA") b++; else if(s=="TLE") c++; else if(s=="RE") d++; } cout<<"AC x "<<a<<"\nWA x "<<b<<"\nTLE x "<<c<<"\nRE x "<<d;; }
#include<iostream> #include<unordered_map> using namespace std; int n; unordered_map<string,int>m; string s,k[4]={"AC","WA","TLE","RE"}; int main(){ cin>>n; while(n--){ cin>>s; m[s]++; } for(n=0;n<4;n++){ cout<<k[n]<<" x "<<m[k[n]]<<"\n"; } }
#include<bits/stdc++.h> using namespace std; map<string,int>num; int main() { int n; scanf("%d",&n); for(int i=1;i<=n;i++) { string s; cin>>s; num[s]++; } printf("AC x %d\n",num["AC"]); printf("WA x %d\n",num["WA"]); printf("TLE x %d\n",num["TLE"]); printf("RE x %d\n",num["RE"]); return 0; }
#include<bits/stdc++.h> using namespace std; int main() { int t; cin >> t; map<string, int> cnt; while(t--) { string s; cin >> s; cnt[s]++; } string x[] = {"AC", "WA", "TLE", "RE"}; for(int i = 0; i < 4; i++) { cout << x[i] << " x " << cnt[x[i]] << "\n"; } }
#include <bits/stdc++.h> using namespace std; string s; int a[6]; int main() { int t; cin>>t; while(t--) { cin>>s; if(s=="AC") ++a[0]; else if(s=="WA") ++a[1]; else if(s=="TLE") ++a[2]; else if(s=="RE") ++a[3]; } cout<<"AC x "<<a[0]<<"\nWA x "<<a[1]<<"\nTLE x "<<a[2]<<"\nRE x "<<a[3]<<"\n"; return 0; }
#include<bits/stdc++.h> using namespace std; int main() { int n,x=1000; cin>>n; string ip; map<string,int> fr; for(int i=1;i<=n;i++) { cin>>ip; fr[ip]++; } cout<<"AC x "<<fr["AC"]<<endl; cout<<"WA x "<<fr["WA"]<<endl; cout<<"TLE x "<<fr["TLE"]<<endl; cout<<"RE x "<<fr["RE"]<<endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); i++) #define all(v) begin(v),end(v) using ll = long long; int main() { int n;cin>>n; map<string,int> m; rep(i,n){ string s;cin>>s; m[s]++; } for(string s:{"AC","WA","TLE","RE"}){ cout<<s<<" x "<<m[s]<<endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; string s; map <string,int> mp; while(n--) { cin>>s; mp[s]++; } cout<<"AC x "<<mp["AC"]<<endl; cout<<"WA x "<<mp["WA"]<<endl; cout<<"TLE x "<<mp["TLE"]<<endl; cout<<"RE x "<<mp["RE"]<<endl; return 0; }
#include<iostream> #include<string> #include<map> using namespace std; int main() { int n; scanf("%d",&n); map<string, int> mp; for(int i=1;i<=n;i++){ string s; cin >> s; mp[s]++; } printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", mp["AC"], mp["WA"], mp["TLE"], mp["RE"]); return 0; }
#include<iostream> #include<map> #include<string> using namespace std; int main() { int N; cin >> N; map<string, int> cnt; for (int i = 0; i < N; i++) { string s; cin >> s; cnt[s]++; } for (string s : {"AC", "WA", "TLE", "RE"}) { cout << s << " x " << cnt[s] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; long long n; map<string, int> mp; string st[] = {"AC", "WA", "TLE", "RE"}; int main() { cin >> n; for (int i = 0; i < n; ++i) { string s; cin >> s; ++mp[s]; } for (int i = 0; i < 4; ++i) cout << st[i] << " x " << mp[st[i]] << endl; return 0; }
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll n; string stu[5]={"AC","WA","TLE","RE"}; string s; ll num[5]; int main(){ cin>>n; for(ll i=0;i<n;i++){ cin>>s; for(ll j=0;j<4;j++) if(s==stu[j]) num[j]++; } for(ll i=0;i<4;i++) cout<<stu[i]<<" x "<<num[i]<<endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin>>n; unordered_map<string,int> m; for(int i=0;i<n;i++){ string s; cin>>s; m[s]++; } cout<<"AC x "<<m["AC"]<<endl; cout<<"WA x "<<m["WA"]<<endl; cout<<"TLE x "<<m["TLE"]<<endl; cout<<"RE x "<<m["RE"]<<endl; }
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; map<string,int>m; for(int i=0;i<n;i++) { string s; cin>>s; m[s]++; } cout<<"AC x "<<m["AC"]<<endl; cout<<"WA x "<<m["WA"]<<endl; cout<<"TLE x "<<m["TLE"]<<endl; cout<<"RE x "<<m["RE"]<<endl; }
#include <iostream> using namespace std; #include <map> int main(){ map<string,int> ans; int n; cin >> n; while(n--){ string str;cin >> str; ans[str]++; } string res[] = {"AC","WA","TLE","RE"}; for(auto &a:res){ printf("%s x %d\n",a.c_str(),ans[a]); } }
#include<bits/stdc++.h> using namespace std; int main() { long n; cin>>n; string s; long a=0,t=0,w=0,r=0; for(long i=1;i<=n;++i) { cin>>s; if(s[0]=='A') ++a; else if(s[0]=='W') ++w; else if(s[0]=='T') ++t; else if(s[0]=='R') ++r; } printf("AC x %ld\nWA x %ld\nTLE x %ld\nRE x %ld", a,w,t,r); return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ int n; int a[4]={0,0,0,0}; string r[4]={"AC","WA","TLE","RE"}; cin>>n; while(n--){ string s; cin>>s; int i=0; while(r[i]!=s){ i++; } a[i]++; } for(int i=0;i<4;i++){ cout<<r[i]<<" x "<<a[i]<<endl; } return(0); }
#include<bits/stdc++.h> using namespace std; int n; int main() { int ac=0,re=0,tle=0,wa=0,i; scanf("%d",&n); for(i=0;i<n;i++) { char p[5]; scanf("%s",p); if(p[0]=='A')ac++; if(p[0]=='T')tle++; if(p[0]=='W')wa++; if(p[0]=='R')re++; } printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d",ac,wa,tle,re); }
#include<bits/stdc++.h> using namespace std; int main(){ map<string,int>mp; mp["AC"]=0;mp["WA"]=1;mp["TLE"]=2;mp["RE"]=3; int cnt[4]={0,0,0,0}; int n;cin>>n;for(int i=0;i<n;i++){ string s;cin>>s;cnt[mp[s]]++; } printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d",cnt[0],cnt[1],cnt[2],cnt[3]); }
#include<bits/stdc++.h> using namespace std; #define ll long long int main(){ int n; map<string,int> m; string x; cin>> n; for(int i =0; i<n; i++){ cin>>x; m[x]++; } cout<<"AC x "<<m["AC"]<<"\nWA x "<<m["WA"]<<"\nTLE x "<<m["TLE"]<<"\nRE x "<<m["RE"]; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int N; cin >> N; unordered_map<string, int> freq; for (string line; getline(cin, line);) { freq[line]++; } for (string status: {"AC", "WA", "TLE", "RE"}) cout << status << " x " << freq[status] << '\n'; }
#include<bits/stdc++.h> using namespace std; string s; int a[4],n; int main(){ cin>>n; for(int i=0;i<n;i++){ cin>>s; if(s=="AC") a[0]++; if(s=="WA") a[1]++; if(s=="TLE") a[2]++; if(s=="RE") a[3]++; } printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a[0],a[1],a[2],a[3]); }
#include<iostream> #include<map> using namespace std; int n; string st; map<string,int> mp; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) cin>>st,mp[st]++; printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",mp["AC"],mp["WA"],mp["TLE"],mp["RE"]); }
#include<bits/stdc++.h> using namespace std; void solve(){ int n; string s; cin>>n; map<string, int> mp; for(int i=0;i<n;i++){ cin>>s; mp[s]++; } cout<<"AC x "<<mp["AC"]<<"\n"; cout<<"WA x "<<mp["WA"]<<"\n"; cout<<"TLE x "<<mp["TLE"]<<"\n"; cout<<"RE x "<<mp["RE"]<<"\n"; } int main(){ solve(); }
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; map<string,int> m; string s; for(int i=1;i<=n;i++) { cin>>s; m[s]++; } cout<<"AC x "<<m["AC"]<<endl; cout<<"WA x "<<m["WA"]<<endl; cout<<"TLE x "<<m["TLE"]<<endl; cout<<"RE x "<<m["RE"]<<endl; return 0; }
#include<bits/stdc++.h> using namespace std; int main(){int a=0,w=0,r=0,t=0,s;cin>>s;string d; for(int i=0;i<s;i++){cin>>d;if(d=="AC")a++;else if(d=="WA")w++;else if(d=="RE")r++;else t++;} cout<<"AC x "<<a<<endl;cout<<"WA x "<<w<<endl; cout<<"TLE x "<<t<<endl; cout<<"RE x "<<r<<endl;}
#include<bits/stdc++.h> using namespace std; int main() { map<string,int>m; int n; cin>>n; while(n--) { string s; cin>>s; m[s]++; } cout<<"AC x "<<m["AC"]<<endl; cout<<"WA x "<<m["WA"]<<endl; cout<<"TLE x "<<m["TLE"]<<endl; cout<<"RE x "<<m["RE"]<<endl; }
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; int i; map <string,int> cnt; string S; for(i = 0;i < N;i++){ cin >> S; cnt[S]++; } for(string s : {"AC","WA","TLE","RE"}){ cout << s << " x " << cnt[s] << endl; } return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ map<string,int>ans; int n; cin>>n; while(n--){ string s; cin>>s; ans[s]++; } cout<<"AC x "<<ans["AC"]<<endl; cout<<"WA x "<<ans["WA"]<<endl; cout<<"TLE x "<<ans["TLE"]<<endl; cout<<"RE x "<<ans["RE"]<<endl; }
#include<bits/stdc++.h> #define MAXN using namespace std; map <string,int> m; int main() { int n; scanf("%d",&n); for(int i = 1;i <= n;i ++) { string s; cin >> s; m[s] ++; } printf("AC x %d\n",m["AC"]); printf("WA x %d\n",m["WA"]); printf("TLE x %d\n",m["TLE"]); printf("RE x %d\n",m["RE"]); return 0; }
#include<bits/stdc++.h> using namespace std; int main( ){ int n,i,j; string s; unordered_map<string,int> m; cin>>n; for(i=0;i<n;i++){ cin>>s; m[s]++; } string p[4]={"AC","WA","TLE","RE"}; for(i=0;i<4;i++){ cout<<p[i]<<" "<<"x"<<" "<<m[p[i]]<<endl; } return 0; }
#include<bits/stdc++.h> using namespace std; int main() { long long int test,n,i,j,k,x,y,t; cin>>test; map<string,long>p; while(test--){ string s; cin>>s; p[s]++; } cout<<"AC x "<<p["AC"]<<endl; cout<<"WA x "<<p["WA"]<<endl; cout<<"TLE x "<<p["TLE"]<<endl; cout<<"RE x "<<p["RE"]<<endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll cnt[4]={}; ll n; cin>>n; string a[4]={"AC","WA","TLE","RE"}; for(int i=0;i<n;i++){ string s; cin>>s; for(int i=0;i<4;i++)if(s==a[i])cnt[i]++; } for(int i=0;i<4;i++){ cout<<a[i]<<" x "<<cnt[i]<<endl; } return 0; }
#include<iostream> #include<map> using namespace std; map<string,int> M; int main() { string s; int n; cin >> n; while(n--) { cin >> s; ++M[s]; } printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",M["AC"],M["WA"],M["TLE"],M["RE"]); return 0; }
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; unordered_map<string ,int> m; for(int i=0;i<n;i++) { string str; cin>>str; m[str]++; } cout<<"AC x "<<m["AC"]<<endl; cout<<"WA x "<<m["WA"]<<endl; cout<<"TLE x "<<m["TLE"]<<endl; cout<<"RE x "<<m["RE"]<<endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; map<string, int> mp; for (int i = 0; i < n; i++) { cin >> s; mp[s]++; } string str[4] = {"AC", "WA", "TLE", "RE"}; for (int i = 0; i < 4; i++) { cout << str[i] << " x " << mp[str[i]] << endl; } }
#include<cstdio> int n,a,b,c,d; char str[20]; int main() { scanf("%d",&n); for (int i=1;i<=n;++i) { scanf("%s",&str); if (str[0]=='A') ++a; if (str[0]=='W') ++b; if (str[0]=='T') ++c; if (str[0]=='R') ++d; } printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a,b,c,d); return 0; }
#include <bits/stdc++.h> using namespace std; int main() {int N; cin >> N; string S; map<string, int> m; while (N--) cin >> S, ++m[S]; for (auto s : {"AC", "WA", "TLE", "RE"}) printf("%s x %d\n", s, m[s]);}
#include <bits/stdc++.h> using namespace std; map<string, int> mp; int N; int main(){ cin>>N; while (N--){ string s; cin>>s; mp[s]++; } cout<<"AC x "<<mp["AC"]<<endl; cout<<"WA x "<<mp["WA"]<<endl; cout<<"TLE x "<<mp["TLE"]<<endl; cout<<"RE x "<<mp["RE"]<<endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<string, int> m; string s; for (int i = 0; i < n; i++) { cin >> s; m[s] += 1; } vector<string> v = {"AC", "WA", "TLE", "RE"}; for (auto i : v) { cout << i << " x " << m[i] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; map<string, int> cnt; for(int i = 0; i < n; ++i) { string s; cin >> s; cnt[s] += 1; } for(auto s : {"AC", "WA", "TLE", "RE"}) { cout << s << " x " << cnt[s] << '\n'; } }
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; map<string,int> A; for(int i=0;i<N;i++){ string S; cin >> S; A[S]++; } cout << "AC x " << A["AC"] << endl; cout << "WA x " << A["WA"] << endl; cout << "TLE x " << A["TLE"] << endl; cout << "RE x " << A["RE"] << endl; }
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; unordered_map<string,int> mp; for(int i=0;i<n;i++){ string s;cin>>s; mp[s]++; } cout<<"AC x "<<mp["AC"]<<endl; cout<<"WA x "<<mp["WA"]<<endl; cout<<"TLE x "<<mp["TLE"]<<endl; cout<<"RE x "<<mp["RE"]<<endl; return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int a=0,b=0,c=0,d=0; while(n--){ string s; cin>>s; if(s=="AC")a++; else if(s=="WA")b++; else if(s=="TLE")c++; else d++; } cout<<"AC x "<<a; cout<<"\nWA x "<<b<<"\n"; cout<<"TLE x "<<c<<"\n"; cout<<"RE x "<<d; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<string, int> cnt; for (int i = 0; i < n; i++){ string s ; cin >> s; cnt[s]++; } for(string x : {"AC", "WA", "TLE", "RE"}){ cout << x << " x " << cnt[x] << endl; } }