# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
631313 | 2022-08-18T03:09:51 Z | TranGiaHuy1508 | Brunhilda’s Birthday (BOI13_brunhilda) | C++17 | 1000 ms | 124488 KB |
/* Unknown's C++ Template (v3.2) */ #include "bits/stdc++.h" using namespace std; // #define int long long using ll = long long; using ld = long double; using ii = pair<int, int>; using vi = vector<int>; using vii = vector<ii>; using vvi = vector<vi>; using vvii = vector<vii>; template <class T> using maxpq = priority_queue<T>; template <class T> using minpq = priority_queue<T, vector<T>, greater<T>>; #define pb push_back #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define mid ((l+r)>>1) #define fi first #define se second #ifdef LOCAL #define debug(x) cout << #x << " = " << x << "\n"; #else #define debug(x) ; #endif template <class A, class B> ostream& operator << (ostream& out, pair<A, B> x) { out << "(" << x.first << ", " << x.second << ")"; return out; } template <class T> ostream& operator << (ostream& out, vector<T> x){ out << "["; for (int i=0; i<sz(x); i++) { out << (i ? ", " : "") << x[i]; } out << "]"; return out; } template <class T> istream& operator >> (istream& in, vector<T> &x){ for (auto &i: x) in >> i; return in; } const ld PI = acos(-1.0); const int allmod[3] = {(int)1e9+7, 998244353, (int)1e9+9}; const int mod = allmod[0]; const int maxn = 2e5 + 64; const int inf = 1e9; const ld eps = 1e-6; const int multitest = 0; const int maxval = 1e7 + 10; int dp[maxval]; vector<int> *divs[maxval]; void main_program(){ int m, Q; cin >> m >> Q; vi v(m); cin >> v; sort(all(v)); divs[0] = new vector<int>; for (int i = 0; i < m; i++) divs[0]->push_back(v[i]); for (int i = 0; i < maxval; i++){ dp[i] = inf; } dp[0] = 0; int x = 0, lim = 1; while (lim < maxval){ if (divs[x]){ for (auto i: *divs[x]){ while (lim < min(x + i, maxval)){ dp[lim] = dp[x] + 1; lim++; } if (x + i < maxval){ if (!divs[x + i]) divs[x + i] = new vector<int>; divs[x + i]->push_back(i); } } delete divs[x]; } x++; } for (int i = 0; i < Q; i++){ int a; cin >> a; if (dp[a] == inf) cout << "oo\n"; else cout << dp[a] << "\n"; } } void pre_main(){ } signed main(){ #ifdef LOCAL auto stime = chrono::high_resolution_clock::now(); #endif ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifndef ONLINE_JUDGE if (fopen(".inp", "r")){ freopen(".inp", "r", stdin); freopen(".out", "w", stdout); } #endif int t = 1; if (multitest) cin >> t; pre_main(); while (t--) main_program(); #ifdef LOCAL auto etime = chrono::high_resolution_clock::now(); auto duration = chrono::duration_cast<chrono::milliseconds>(etime-stime).count(); cout << "\n[" << duration << "ms]\n"; #endif }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 191 ms | 117708 KB | Output isn't correct |
2 | Correct | 537 ms | 117940 KB | Output is correct |
3 | Correct | 429 ms | 117828 KB | Output is correct |
4 | Correct | 134 ms | 117724 KB | Output is correct |
5 | Correct | 245 ms | 117644 KB | Output is correct |
6 | Incorrect | 199 ms | 117624 KB | Output isn't correct |
7 | Correct | 433 ms | 117680 KB | Output is correct |
8 | Correct | 582 ms | 117612 KB | Output is correct |
9 | Correct | 731 ms | 117672 KB | Output is correct |
10 | Correct | 816 ms | 117628 KB | Output is correct |
11 | Correct | 611 ms | 117776 KB | Output is correct |
12 | Correct | 121 ms | 117692 KB | Output is correct |
13 | Execution timed out | 1087 ms | 113368 KB | Time limit exceeded |
14 | Execution timed out | 1103 ms | 114972 KB | Time limit exceeded |
15 | Correct | 545 ms | 117712 KB | Output is correct |
16 | Correct | 544 ms | 117636 KB | Output is correct |
17 | Correct | 257 ms | 117716 KB | Output is correct |
18 | Correct | 132 ms | 117700 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 257 ms | 117944 KB | Output is correct |
2 | Correct | 214 ms | 123172 KB | Output is correct |
3 | Execution timed out | 1101 ms | 102928 KB | Time limit exceeded |
4 | Correct | 356 ms | 117908 KB | Output is correct |
5 | Correct | 896 ms | 121148 KB | Output is correct |
6 | Correct | 416 ms | 117664 KB | Output is correct |
7 | Correct | 262 ms | 118004 KB | Output is correct |
8 | Correct | 324 ms | 117916 KB | Output is correct |
9 | Execution timed out | 1089 ms | 122460 KB | Time limit exceeded |
10 | Execution timed out | 1089 ms | 103032 KB | Time limit exceeded |
11 | Execution timed out | 1090 ms | 101948 KB | Time limit exceeded |
12 | Correct | 691 ms | 118036 KB | Output is correct |
13 | Correct | 249 ms | 117068 KB | Output is correct |
14 | Correct | 381 ms | 117848 KB | Output is correct |
15 | Execution timed out | 1099 ms | 114084 KB | Time limit exceeded |
16 | Correct | 208 ms | 123108 KB | Output is correct |
17 | Execution timed out | 1091 ms | 112308 KB | Time limit exceeded |
18 | Execution timed out | 1106 ms | 124360 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1095 ms | 112636 KB | Time limit exceeded |
2 | Execution timed out | 1096 ms | 103268 KB | Time limit exceeded |
3 | Execution timed out | 1059 ms | 101148 KB | Time limit exceeded |
4 | Correct | 769 ms | 118184 KB | Output is correct |
5 | Correct | 340 ms | 124244 KB | Output is correct |
6 | Execution timed out | 1050 ms | 118696 KB | Time limit exceeded |
7 | Correct | 870 ms | 124484 KB | Output is correct |
8 | Execution timed out | 1073 ms | 111404 KB | Time limit exceeded |
9 | Execution timed out | 1098 ms | 113276 KB | Time limit exceeded |
10 | Correct | 689 ms | 118084 KB | Output is correct |
11 | Correct | 556 ms | 118012 KB | Output is correct |
12 | Execution timed out | 1004 ms | 118212 KB | Time limit exceeded |
13 | Execution timed out | 1104 ms | 111924 KB | Time limit exceeded |
14 | Correct | 888 ms | 118336 KB | Output is correct |
15 | Execution timed out | 1097 ms | 115880 KB | Time limit exceeded |
16 | Execution timed out | 1094 ms | 111472 KB | Time limit exceeded |
17 | Correct | 987 ms | 120696 KB | Output is correct |
18 | Execution timed out | 1089 ms | 103264 KB | Time limit exceeded |
19 | Correct | 339 ms | 117112 KB | Output is correct |
20 | Execution timed out | 1089 ms | 101376 KB | Time limit exceeded |
21 | Correct | 973 ms | 118440 KB | Output is correct |
22 | Execution timed out | 1097 ms | 105356 KB | Time limit exceeded |
23 | Correct | 398 ms | 120044 KB | Output is correct |
24 | Correct | 220 ms | 117988 KB | Output is correct |
25 | Correct | 783 ms | 118172 KB | Output is correct |
26 | Correct | 772 ms | 118448 KB | Output is correct |
27 | Execution timed out | 1080 ms | 98140 KB | Time limit exceeded |
28 | Correct | 296 ms | 117364 KB | Output is correct |
29 | Execution timed out | 1099 ms | 116536 KB | Time limit exceeded |
30 | Execution timed out | 1104 ms | 122300 KB | Time limit exceeded |
31 | Correct | 375 ms | 117948 KB | Output is correct |
32 | Correct | 439 ms | 118104 KB | Output is correct |
33 | Correct | 173 ms | 117720 KB | Output is correct |
34 | Correct | 861 ms | 124488 KB | Output is correct |
35 | Correct | 320 ms | 118088 KB | Output is correct |
36 | Execution timed out | 1100 ms | 107384 KB | Time limit exceeded |
37 | Correct | 342 ms | 124252 KB | Output is correct |
38 | Execution timed out | 1054 ms | 118640 KB | Time limit exceeded |
39 | Correct | 262 ms | 118012 KB | Output is correct |
40 | Correct | 977 ms | 118500 KB | Output is correct |
41 | Correct | 839 ms | 123780 KB | Output is correct |
42 | Execution timed out | 1065 ms | 105028 KB | Time limit exceeded |