#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, q;
ll a[200002];
ll val[200002];
ll cnt[200002];
int main(){
ios_base::sync_with_stdio(false), cin.tie(nullptr);
cin >> n;
for(int i=1; i<=n; i++){
cin >> a[i];
ll tmp = a[i];
while(tmp%2==0){
tmp /= 2;
}
val[i] = tmp;
cnt[i] = a[i]/tmp + cnt[i-1];
}
cin >> q;
while(q--){
ll x;
cin >> x;
ll h = lower_bound(cnt+1, cnt+n+1, x) - cnt;
cout << val[h]<< '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
21 ms |
5088 KB |
Output is correct |
4 |
Correct |
32 ms |
1900 KB |
Output is correct |
5 |
Correct |
54 ms |
5592 KB |
Output is correct |
6 |
Correct |
31 ms |
4600 KB |
Output is correct |
7 |
Correct |
54 ms |
5560 KB |
Output is correct |
8 |
Correct |
48 ms |
5612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
324 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
292 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
21 ms |
5088 KB |
Output is correct |
4 |
Correct |
32 ms |
1900 KB |
Output is correct |
5 |
Correct |
54 ms |
5592 KB |
Output is correct |
6 |
Correct |
31 ms |
4600 KB |
Output is correct |
7 |
Correct |
54 ms |
5560 KB |
Output is correct |
8 |
Correct |
48 ms |
5612 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
292 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
32 ms |
3280 KB |
Output is correct |
24 |
Correct |
35 ms |
6344 KB |
Output is correct |
25 |
Correct |
71 ms |
10296 KB |
Output is correct |
26 |
Correct |
48 ms |
6600 KB |
Output is correct |
27 |
Correct |
43 ms |
6732 KB |
Output is correct |
28 |
Correct |
78 ms |
10704 KB |
Output is correct |
29 |
Correct |
83 ms |
10240 KB |
Output is correct |
30 |
Correct |
41 ms |
3916 KB |
Output is correct |
31 |
Correct |
79 ms |
10676 KB |
Output is correct |