#include <bits/stdc++.h>
using namespace std;
const int P = 1e7+10;
const int M = 1e5+10;
struct Node {
int v;
Node * nxt;
};
int mx;
Node * q[P];
int dp[P];
Node* add(Node * no, int x) {
if(no == 0) return new Node({x, 0});
no->nxt = add(no->nxt, x);
return no;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int m, Q;
cin >> m >> Q;
for(int i = 0; i < m; i++) {
int x;
cin >> x;
q[0] = add(q[0], x);
}
for(int i = 1; i < P; i++) dp[i] = 1e9+10;
for(int i = 0; i < P; i++) {
Node* cur = q[i];
while(cur) {
int p = cur->v;
int nxt = i+p;
int til = min(nxt, P);
for(int j = max(mx, i+1); j < til; j++) {
dp[j] = dp[i]+1;
}
mx = max(mx, nxt);
if(nxt < P) q[nxt] = add(q[nxt], p);
cur = cur->nxt;
}
}
for(int i = 0; i < Q; i++) {
int x;
cin >> x;
if(dp[x] > 1e9) cout << "oo" << endl;
else cout << dp[x] << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
262 ms |
173816 KB |
Output is correct |
2 |
Execution timed out |
1100 ms |
262144 KB |
Time limit exceeded |
3 |
Execution timed out |
1086 ms |
262144 KB |
Time limit exceeded |
4 |
Correct |
198 ms |
262144 KB |
Output is correct |
5 |
Correct |
383 ms |
262144 KB |
Output is correct |
6 |
Correct |
280 ms |
262144 KB |
Output is correct |
7 |
Execution timed out |
1074 ms |
262144 KB |
Time limit exceeded |
8 |
Execution timed out |
1103 ms |
262144 KB |
Time limit exceeded |
9 |
Execution timed out |
1098 ms |
262144 KB |
Time limit exceeded |
10 |
Execution timed out |
1107 ms |
262144 KB |
Time limit exceeded |
11 |
Execution timed out |
1107 ms |
262144 KB |
Time limit exceeded |
12 |
Correct |
164 ms |
262144 KB |
Output is correct |
13 |
Execution timed out |
1094 ms |
262144 KB |
Time limit exceeded |
14 |
Execution timed out |
1116 ms |
262144 KB |
Time limit exceeded |
15 |
Execution timed out |
1069 ms |
262144 KB |
Time limit exceeded |
16 |
Execution timed out |
1096 ms |
262144 KB |
Time limit exceeded |
17 |
Correct |
385 ms |
262144 KB |
Output is correct |
18 |
Correct |
193 ms |
262144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
808 ms |
262144 KB |
Output is correct |
2 |
Execution timed out |
1083 ms |
262144 KB |
Time limit exceeded |
3 |
Execution timed out |
1081 ms |
262144 KB |
Time limit exceeded |
4 |
Execution timed out |
1091 ms |
262144 KB |
Time limit exceeded |
5 |
Execution timed out |
1083 ms |
262144 KB |
Time limit exceeded |
6 |
Execution timed out |
1074 ms |
262144 KB |
Time limit exceeded |
7 |
Correct |
845 ms |
262144 KB |
Output is correct |
8 |
Correct |
507 ms |
262144 KB |
Output is correct |
9 |
Execution timed out |
1091 ms |
262144 KB |
Time limit exceeded |
10 |
Execution timed out |
1082 ms |
262144 KB |
Time limit exceeded |
11 |
Execution timed out |
1084 ms |
262144 KB |
Time limit exceeded |
12 |
Execution timed out |
1113 ms |
262144 KB |
Time limit exceeded |
13 |
Correct |
397 ms |
262144 KB |
Output is correct |
14 |
Execution timed out |
1118 ms |
262144 KB |
Time limit exceeded |
15 |
Execution timed out |
1081 ms |
262144 KB |
Time limit exceeded |
16 |
Execution timed out |
1085 ms |
262144 KB |
Time limit exceeded |
17 |
Execution timed out |
1112 ms |
262144 KB |
Time limit exceeded |
18 |
Execution timed out |
1068 ms |
262144 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
262144 KB |
Time limit exceeded |
2 |
Execution timed out |
1076 ms |
262144 KB |
Time limit exceeded |
3 |
Execution timed out |
1085 ms |
262144 KB |
Time limit exceeded |
4 |
Execution timed out |
1104 ms |
262144 KB |
Time limit exceeded |
5 |
Execution timed out |
1079 ms |
262144 KB |
Time limit exceeded |
6 |
Execution timed out |
1097 ms |
262144 KB |
Time limit exceeded |
7 |
Execution timed out |
1080 ms |
262144 KB |
Time limit exceeded |
8 |
Execution timed out |
1090 ms |
262144 KB |
Time limit exceeded |
9 |
Execution timed out |
1077 ms |
262144 KB |
Time limit exceeded |
10 |
Execution timed out |
1086 ms |
262144 KB |
Time limit exceeded |
11 |
Execution timed out |
1089 ms |
262144 KB |
Time limit exceeded |
12 |
Execution timed out |
1093 ms |
262144 KB |
Time limit exceeded |
13 |
Execution timed out |
1080 ms |
262144 KB |
Time limit exceeded |
14 |
Execution timed out |
1116 ms |
262144 KB |
Time limit exceeded |
15 |
Execution timed out |
1101 ms |
262144 KB |
Time limit exceeded |
16 |
Execution timed out |
1113 ms |
262144 KB |
Time limit exceeded |
17 |
Execution timed out |
1086 ms |
262144 KB |
Time limit exceeded |
18 |
Execution timed out |
1082 ms |
262144 KB |
Time limit exceeded |
19 |
Execution timed out |
1063 ms |
262144 KB |
Time limit exceeded |
20 |
Execution timed out |
1091 ms |
262144 KB |
Time limit exceeded |
21 |
Execution timed out |
1106 ms |
262144 KB |
Time limit exceeded |
22 |
Execution timed out |
1084 ms |
262144 KB |
Time limit exceeded |
23 |
Execution timed out |
1089 ms |
262144 KB |
Time limit exceeded |
24 |
Correct |
458 ms |
262144 KB |
Output is correct |
25 |
Execution timed out |
1093 ms |
262144 KB |
Time limit exceeded |
26 |
Execution timed out |
1097 ms |
262144 KB |
Time limit exceeded |
27 |
Execution timed out |
1089 ms |
262144 KB |
Time limit exceeded |
28 |
Correct |
617 ms |
262144 KB |
Output is correct |
29 |
Execution timed out |
1085 ms |
262144 KB |
Time limit exceeded |
30 |
Execution timed out |
1084 ms |
262144 KB |
Time limit exceeded |
31 |
Execution timed out |
1065 ms |
262144 KB |
Time limit exceeded |
32 |
Execution timed out |
1040 ms |
262144 KB |
Time limit exceeded |
33 |
Correct |
384 ms |
262144 KB |
Output is correct |
34 |
Execution timed out |
1074 ms |
262144 KB |
Time limit exceeded |
35 |
Correct |
653 ms |
262144 KB |
Output is correct |
36 |
Execution timed out |
1079 ms |
262144 KB |
Time limit exceeded |
37 |
Execution timed out |
1083 ms |
262144 KB |
Time limit exceeded |
38 |
Execution timed out |
1101 ms |
262144 KB |
Time limit exceeded |
39 |
Correct |
604 ms |
262144 KB |
Output is correct |
40 |
Execution timed out |
1095 ms |
262144 KB |
Time limit exceeded |
41 |
Execution timed out |
1085 ms |
262144 KB |
Time limit exceeded |
42 |
Execution timed out |
1115 ms |
262144 KB |
Time limit exceeded |