# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
74484 | 2018-09-02T12:06:38 Z | SpeedOfMagic | Brunhilda’s Birthday (BOI13_brunhilda) | C++17 | 28 ms | 23524 KB |
/** MIT License Copyright (c) 2018 Vasilyev Daniil **/ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; #pragma GCC optimize("Ofast") template<typename T> using v = vector<T>; template<typename T, typename U> using hmap = __gnu_pbds::gp_hash_table<T, U>; //#define int long long typedef long double ld; typedef string str; typedef vector<int> vint; #define rep(a, l, r) for(int a = (l); a < (r); a++) #define pb push_back #define fs first #define sc second #define sz(a) ((int) a.size()) const long long inf = 4611686018427387903; //2^62 - 1 #if 0 //FileIO const string fileName = ""; ifstream fin ((fileName == "" ? "input.txt" : fileName + ".in" )); ofstream fout((fileName == "" ? "output.txt" : fileName + ".out")); #define get fin>> #define put fout<< #else #define get cin>> #define put cout<< #endif #define eol put endl #define check(a) put #a << ": " << a << endl; void read() {} template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get (arg) ;read(args...) ;} void print(){} template<typename Arg,typename... Args> void print(Arg arg,Args... args){put (arg)<<" ";print(args...);} void debug(){eol;} template<typename Arg,typename... Args> void debug(Arg arg,Args... args){put (arg)<<" ";debug(args...);} int getInt(){int a; get a; return a;} //code goes here const long long N = 1e4 + 1; const int LIM = 230; vint erato[N]; int dp[N]; void run() { int m, q; read(m, q); vint primes; int p[m]; rep(i, 0, m) { get p[i]; if (p[i] > LIM) for (int j = 1; j * p[i] < N; j++) erato[j * p[i]].pb(i); else primes.pb(p[i]); } long long mul = 1; rep(i, 0, m) { mul *= p[i]; if (mul > N) { mul = 1e9; break; } } dp[0] = 0; int cur[m]; rep(i, 0, m) cur[i] = 1; int pen = 0; map<int, int> mx; rep(i, 0, m) if (p[i] > LIM) mx[1]++; rep(i, 1, N) { for (int j : erato[i]) { mx[cur[j]]--; if (mx[cur[j]] == 0) mx.erase(cur[j]); cur[j] = -pen; mx[cur[j]]++; } int d = 0; if (!mx.empty()) d = ((*mx.rbegin()).fs) + pen; for (int j : primes) d = max(d, i % j); dp[i] = dp[i - d] + 1; pen++; } rep(i, 0, q) { int n; get n; if (n >= mul) put "oo"; else put dp[n]; eol; } } int32_t main() {srand(time(0)); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); put fixed; put setprecision(15); run(); return 0;}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 620 KB | Output is correct |
2 | Correct | 4 ms | 636 KB | Output is correct |
3 | Correct | 3 ms | 676 KB | Output is correct |
4 | Correct | 19 ms | 900 KB | Output is correct |
5 | Correct | 3 ms | 900 KB | Output is correct |
6 | Correct | 4 ms | 1000 KB | Output is correct |
7 | Correct | 2 ms | 1000 KB | Output is correct |
8 | Correct | 2 ms | 1136 KB | Output is correct |
9 | Correct | 2 ms | 1136 KB | Output is correct |
10 | Correct | 4 ms | 1136 KB | Output is correct |
11 | Correct | 5 ms | 1136 KB | Output is correct |
12 | Correct | 3 ms | 1136 KB | Output is correct |
13 | Correct | 8 ms | 1136 KB | Output is correct |
14 | Correct | 21 ms | 1288 KB | Output is correct |
15 | Correct | 3 ms | 1288 KB | Output is correct |
16 | Correct | 4 ms | 1288 KB | Output is correct |
17 | Correct | 22 ms | 1288 KB | Output is correct |
18 | Correct | 20 ms | 1288 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 6 ms | 1824 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Runtime error | 16 ms | 3828 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Runtime error | 15 ms | 4308 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
4 | Runtime error | 5 ms | 4308 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
5 | Runtime error | 15 ms | 4308 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
6 | Runtime error | 4 ms | 4308 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
7 | Runtime error | 5 ms | 4308 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
8 | Runtime error | 4 ms | 4308 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
9 | Runtime error | 15 ms | 5400 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
10 | Runtime error | 17 ms | 5888 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
11 | Runtime error | 11 ms | 5956 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
12 | Runtime error | 5 ms | 5956 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
13 | Runtime error | 4 ms | 5956 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
14 | Runtime error | 4 ms | 5956 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
15 | Runtime error | 11 ms | 5956 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
16 | Runtime error | 15 ms | 7236 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
17 | Runtime error | 6 ms | 7236 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
18 | Runtime error | 17 ms | 8344 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 13 ms | 8464 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Runtime error | 13 ms | 8636 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Runtime error | 13 ms | 9164 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
4 | Runtime error | 5 ms | 9164 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
5 | Runtime error | 28 ms | 10544 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
6 | Runtime error | 6 ms | 10544 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
7 | Runtime error | 18 ms | 11820 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
8 | Runtime error | 11 ms | 12044 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
9 | Runtime error | 11 ms | 12128 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
10 | Runtime error | 6 ms | 12128 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
11 | Runtime error | 5 ms | 12128 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
12 | Runtime error | 6 ms | 12128 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
13 | Runtime error | 9 ms | 12632 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
14 | Runtime error | 4 ms | 12632 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
15 | Runtime error | 6 ms | 12632 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
16 | Runtime error | 8 ms | 12632 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
17 | Runtime error | 11 ms | 13368 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
18 | Runtime error | 13 ms | 14116 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
19 | Runtime error | 4 ms | 14116 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
20 | Runtime error | 12 ms | 14652 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
21 | Runtime error | 6 ms | 14652 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
22 | Runtime error | 18 ms | 16404 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
23 | Runtime error | 7 ms | 16404 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
24 | Runtime error | 3 ms | 16404 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
25 | Runtime error | 5 ms | 16404 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
26 | Runtime error | 5 ms | 16404 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
27 | Runtime error | 19 ms | 18020 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
28 | Runtime error | 3 ms | 18020 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
29 | Runtime error | 18 ms | 18804 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
30 | Runtime error | 21 ms | 19128 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
31 | Runtime error | 4 ms | 19128 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
32 | Runtime error | 5 ms | 19128 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
33 | Runtime error | 3 ms | 19128 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
34 | Runtime error | 18 ms | 20436 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
35 | Runtime error | 4 ms | 20436 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
36 | Runtime error | 17 ms | 21240 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
37 | Runtime error | 16 ms | 22100 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
38 | Runtime error | 7 ms | 22100 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
39 | Runtime error | 4 ms | 22100 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
40 | Runtime error | 6 ms | 22100 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
41 | Runtime error | 17 ms | 23524 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
42 | Runtime error | 7 ms | 23524 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |