#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
queue<pair<int, int>> q;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
int tz = __builtin_ctz(a);
q.emplace(a >> tz, 1 << tz);
}
int qq;
cin >> qq;
long long prev = 0;
while (qq--) {
long long x;
cin >> x;
long long y = x;
x -= prev;
while (x > q.front().second) {
x -= q.front().second;
q.pop();
}
prev = y;
cout << q.front().first << '\n';
q.front().second -= x;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
14 ms |
2712 KB |
Output is correct |
4 |
Correct |
22 ms |
2000 KB |
Output is correct |
5 |
Correct |
36 ms |
4168 KB |
Output is correct |
6 |
Correct |
23 ms |
2844 KB |
Output is correct |
7 |
Correct |
37 ms |
4188 KB |
Output is correct |
8 |
Correct |
37 ms |
4168 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
456 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
14 ms |
2712 KB |
Output is correct |
4 |
Correct |
22 ms |
2000 KB |
Output is correct |
5 |
Correct |
36 ms |
4168 KB |
Output is correct |
6 |
Correct |
23 ms |
2844 KB |
Output is correct |
7 |
Correct |
37 ms |
4188 KB |
Output is correct |
8 |
Correct |
37 ms |
4168 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
456 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
21 ms |
2868 KB |
Output is correct |
24 |
Correct |
25 ms |
4184 KB |
Output is correct |
25 |
Correct |
51 ms |
7252 KB |
Output is correct |
26 |
Correct |
30 ms |
4700 KB |
Output is correct |
27 |
Correct |
28 ms |
4432 KB |
Output is correct |
28 |
Correct |
53 ms |
7848 KB |
Output is correct |
29 |
Correct |
51 ms |
7176 KB |
Output is correct |
30 |
Correct |
35 ms |
3664 KB |
Output is correct |
31 |
Correct |
54 ms |
7660 KB |
Output is correct |