#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n;
cin >> n;
ll a[n + 1];
for(ll i = 1; i <= n; ++i){
cin >> a[i];
}
map<ll, ll>ans;
ll idx = 1ll;
ll q;
cin >> q;
ll k[q + 1];
for(ll i = 1; i <= q; ++i){
cin >> k[i];
}
ll last = 0ll;
for(ll i = 1; i <= n; ++i){
ll L = last + 1ll;
ll cnt = 1ll;
while(a[i] % 2 == 0){
cnt = cnt * 2ll;
a[i] /= 2;
}
ll R = L + cnt - 1;
while(k[idx] >= L and k[idx] <= R){
ans[k[idx]] = a[i];
idx++;
}
last = R;
}
for(ll i = 1; i <= q; ++i){
cout << ans[k[i]] << '\n';
}
return 0;
// 1000 * 1000 | 33 ?
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
25 ms |
4516 KB |
Output is correct |
4 |
Correct |
55 ms |
6616 KB |
Output is correct |
5 |
Correct |
76 ms |
13020 KB |
Output is correct |
6 |
Correct |
42 ms |
7736 KB |
Output is correct |
7 |
Correct |
75 ms |
14044 KB |
Output is correct |
8 |
Correct |
79 ms |
15528 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 |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 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 |
25 ms |
4516 KB |
Output is correct |
4 |
Correct |
55 ms |
6616 KB |
Output is correct |
5 |
Correct |
76 ms |
13020 KB |
Output is correct |
6 |
Correct |
42 ms |
7736 KB |
Output is correct |
7 |
Correct |
75 ms |
14044 KB |
Output is correct |
8 |
Correct |
79 ms |
15528 KB |
Output is correct |
9 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 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 |
41 ms |
5876 KB |
Output is correct |
24 |
Correct |
39 ms |
7196 KB |
Output is correct |
25 |
Correct |
91 ms |
14676 KB |
Output is correct |
26 |
Correct |
57 ms |
9188 KB |
Output is correct |
27 |
Correct |
48 ms |
7764 KB |
Output is correct |
28 |
Correct |
103 ms |
16632 KB |
Output is correct |
29 |
Correct |
123 ms |
16212 KB |
Output is correct |
30 |
Correct |
64 ms |
11184 KB |
Output is correct |
31 |
Correct |
102 ms |
16468 KB |
Output is correct |