#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<long long, long long>
#define fr first
#define se second
int inf = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 1e7;
int dp[MAXN + 10];
set<pii> s;
int32_t main() {
int n, q;
cin >> n >> q;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
s.insert({a, a});
}
for (int i = 1; i <= MAXN; i++) {
dp[i] = inf;
while ((((*s.begin()).fr + (*s.begin()).se) <= i)) {
auto u = *s.begin();
s.erase(s.begin());
s.insert({u.fr + u.se, u.se});
}
dp[i] = min(dp[i], dp[(*s.begin()).fr] + 1);
}
while (q--) {
int x;
cin >> x;
if (dp[x] == inf) cout << "oo\n";
else cout << dp[x] << "\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
120 ms |
78672 KB |
Output isn't correct |
2 |
Incorrect |
621 ms |
78676 KB |
Output isn't correct |
3 |
Incorrect |
328 ms |
78672 KB |
Output isn't correct |
4 |
Incorrect |
115 ms |
78676 KB |
Output isn't correct |
5 |
Incorrect |
271 ms |
78620 KB |
Output isn't correct |
6 |
Incorrect |
128 ms |
78520 KB |
Output isn't correct |
7 |
Incorrect |
332 ms |
78680 KB |
Output isn't correct |
8 |
Incorrect |
532 ms |
78440 KB |
Output isn't correct |
9 |
Incorrect |
799 ms |
78680 KB |
Output isn't correct |
10 |
Execution timed out |
1057 ms |
72784 KB |
Time limit exceeded |
11 |
Incorrect |
839 ms |
78524 KB |
Output isn't correct |
12 |
Incorrect |
119 ms |
78672 KB |
Output isn't correct |
13 |
Execution timed out |
1082 ms |
34620 KB |
Time limit exceeded |
14 |
Execution timed out |
1020 ms |
33360 KB |
Time limit exceeded |
15 |
Incorrect |
671 ms |
78604 KB |
Output isn't correct |
16 |
Incorrect |
601 ms |
78600 KB |
Output isn't correct |
17 |
Incorrect |
325 ms |
78704 KB |
Output isn't correct |
18 |
Incorrect |
120 ms |
78672 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
321 ms |
79440 KB |
Output isn't correct |
2 |
Incorrect |
286 ms |
84348 KB |
Output isn't correct |
3 |
Execution timed out |
1062 ms |
43496 KB |
Time limit exceeded |
4 |
Incorrect |
564 ms |
78672 KB |
Output isn't correct |
5 |
Execution timed out |
1101 ms |
54352 KB |
Time limit exceeded |
6 |
Incorrect |
480 ms |
78672 KB |
Output isn't correct |
7 |
Incorrect |
279 ms |
79444 KB |
Output isn't correct |
8 |
Incorrect |
488 ms |
78672 KB |
Output isn't correct |
9 |
Execution timed out |
1043 ms |
45552 KB |
Time limit exceeded |
10 |
Execution timed out |
1073 ms |
43492 KB |
Time limit exceeded |
11 |
Execution timed out |
1059 ms |
31244 KB |
Time limit exceeded |
12 |
Execution timed out |
1071 ms |
74580 KB |
Time limit exceeded |
13 |
Incorrect |
231 ms |
78756 KB |
Output isn't correct |
14 |
Incorrect |
568 ms |
78880 KB |
Output isn't correct |
15 |
Execution timed out |
1071 ms |
38432 KB |
Time limit exceeded |
16 |
Incorrect |
290 ms |
84308 KB |
Output isn't correct |
17 |
Execution timed out |
1081 ms |
36436 KB |
Time limit exceeded |
18 |
Execution timed out |
1071 ms |
49492 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1033 ms |
37456 KB |
Time limit exceeded |
2 |
Execution timed out |
1076 ms |
30668 KB |
Time limit exceeded |
3 |
Execution timed out |
1039 ms |
29264 KB |
Time limit exceeded |
4 |
Execution timed out |
1050 ms |
66388 KB |
Time limit exceeded |
5 |
Incorrect |
581 ms |
85072 KB |
Output isn't correct |
6 |
Execution timed out |
1037 ms |
38140 KB |
Time limit exceeded |
7 |
Execution timed out |
1075 ms |
64284 KB |
Time limit exceeded |
8 |
Execution timed out |
1026 ms |
37032 KB |
Time limit exceeded |
9 |
Execution timed out |
1079 ms |
38300 KB |
Time limit exceeded |
10 |
Execution timed out |
1033 ms |
55636 KB |
Time limit exceeded |
11 |
Execution timed out |
1006 ms |
78932 KB |
Time limit exceeded |
12 |
Execution timed out |
1072 ms |
42580 KB |
Time limit exceeded |
13 |
Execution timed out |
1027 ms |
33108 KB |
Time limit exceeded |
14 |
Execution timed out |
1057 ms |
65888 KB |
Time limit exceeded |
15 |
Execution timed out |
1029 ms |
33832 KB |
Time limit exceeded |
16 |
Execution timed out |
1053 ms |
31060 KB |
Time limit exceeded |
17 |
Execution timed out |
1010 ms |
43144 KB |
Time limit exceeded |
18 |
Execution timed out |
1076 ms |
30516 KB |
Time limit exceeded |
19 |
Incorrect |
371 ms |
78928 KB |
Output isn't correct |
20 |
Execution timed out |
1068 ms |
29268 KB |
Time limit exceeded |
21 |
Execution timed out |
1052 ms |
51540 KB |
Time limit exceeded |
22 |
Execution timed out |
1047 ms |
35288 KB |
Time limit exceeded |
23 |
Incorrect |
711 ms |
80724 KB |
Output isn't correct |
24 |
Incorrect |
360 ms |
78932 KB |
Output isn't correct |
25 |
Execution timed out |
1048 ms |
59984 KB |
Time limit exceeded |
26 |
Execution timed out |
1016 ms |
63536 KB |
Time limit exceeded |
27 |
Execution timed out |
1020 ms |
32336 KB |
Time limit exceeded |
28 |
Incorrect |
467 ms |
79004 KB |
Output isn't correct |
29 |
Execution timed out |
1080 ms |
44372 KB |
Time limit exceeded |
30 |
Execution timed out |
1043 ms |
45484 KB |
Time limit exceeded |
31 |
Incorrect |
587 ms |
79184 KB |
Output isn't correct |
32 |
Incorrect |
764 ms |
79192 KB |
Output isn't correct |
33 |
Incorrect |
249 ms |
78928 KB |
Output isn't correct |
34 |
Execution timed out |
1037 ms |
60500 KB |
Time limit exceeded |
35 |
Incorrect |
548 ms |
78932 KB |
Output isn't correct |
36 |
Execution timed out |
1042 ms |
35924 KB |
Time limit exceeded |
37 |
Incorrect |
585 ms |
85084 KB |
Output isn't correct |
38 |
Execution timed out |
1077 ms |
40540 KB |
Time limit exceeded |
39 |
Incorrect |
464 ms |
78932 KB |
Output isn't correct |
40 |
Execution timed out |
1062 ms |
49396 KB |
Time limit exceeded |
41 |
Execution timed out |
1039 ms |
70008 KB |
Time limit exceeded |
42 |
Execution timed out |
1101 ms |
33616 KB |
Time limit exceeded |