#include <bits/stdc++.h>
using namespace std;
#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(0);
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using ld = long double;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = ll(2e18) + ll(1e15);
const double EPS = 1e-8;
static int LamyIsCute = []() {
EmiliaMyWife
return 48763;
}();
signed main() {
int n;
cin >> n;
vector<int> arr(n);
for(int i = 0; i < n; i++)
cin >> arr[i];
ll it = 0, cur = 0, prv = -1;
int q;
cin >> q;
while(q--) {
ll x;
cin >> x;
while(cur < x) {
ll w = 1;
while(arr[it] % 2 == 0)
w *= 2, arr[it] /= 2;
cur += w;
prv = arr[it];
it++;
}
cout << prv << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
16 ms |
1592 KB |
Output is correct |
4 |
Correct |
25 ms |
1604 KB |
Output is correct |
5 |
Correct |
42 ms |
2544 KB |
Output is correct |
6 |
Correct |
24 ms |
2104 KB |
Output is correct |
7 |
Correct |
43 ms |
2600 KB |
Output is correct |
8 |
Correct |
44 ms |
3152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
312 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
312 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
316 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
16 ms |
1592 KB |
Output is correct |
4 |
Correct |
25 ms |
1604 KB |
Output is correct |
5 |
Correct |
42 ms |
2544 KB |
Output is correct |
6 |
Correct |
24 ms |
2104 KB |
Output is correct |
7 |
Correct |
43 ms |
2600 KB |
Output is correct |
8 |
Correct |
44 ms |
3152 KB |
Output is correct |
9 |
Correct |
1 ms |
312 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
312 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
316 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
328 KB |
Output is correct |
23 |
Correct |
25 ms |
2364 KB |
Output is correct |
24 |
Correct |
29 ms |
3104 KB |
Output is correct |
25 |
Correct |
58 ms |
5664 KB |
Output is correct |
26 |
Correct |
40 ms |
3656 KB |
Output is correct |
27 |
Correct |
37 ms |
3272 KB |
Output is correct |
28 |
Correct |
71 ms |
6596 KB |
Output is correct |
29 |
Correct |
68 ms |
5568 KB |
Output is correct |
30 |
Correct |
36 ms |
3296 KB |
Output is correct |
31 |
Correct |
69 ms |
6412 KB |
Output is correct |