#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
const int LIM=2e5+7;
ll T[LIM], pref[LIM];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n;
cin >> n;
rep(i, n) {
cin >> T[i];
pref[i]=1;
while(T[i]%2==0) {
T[i]/=2;
pref[i]*=2;
}
if(i) pref[i]+=pref[i-1];
}
int q;
cin >> q;
while(q--) {
ll x;
cin >> x;
int p=0, k=n-1;
while(p<k) {
int sr=(p+k)/2;
if(pref[sr]<x) p=sr+1; else k=sr;
}
cout << T[p] << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
20 ms |
3868 KB |
Output is correct |
4 |
Correct |
29 ms |
2128 KB |
Output is correct |
5 |
Correct |
58 ms |
4924 KB |
Output is correct |
6 |
Correct |
29 ms |
4036 KB |
Output is correct |
7 |
Correct |
52 ms |
5000 KB |
Output is correct |
8 |
Correct |
49 ms |
5464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
324 KB |
Output is correct |
9 |
Correct |
0 ms |
320 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
20 ms |
3868 KB |
Output is correct |
4 |
Correct |
29 ms |
2128 KB |
Output is correct |
5 |
Correct |
58 ms |
4924 KB |
Output is correct |
6 |
Correct |
29 ms |
4036 KB |
Output is correct |
7 |
Correct |
52 ms |
5000 KB |
Output is correct |
8 |
Correct |
49 ms |
5464 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 |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
316 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
324 KB |
Output is correct |
17 |
Correct |
0 ms |
320 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
324 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
27 ms |
2780 KB |
Output is correct |
24 |
Correct |
33 ms |
4748 KB |
Output is correct |
25 |
Correct |
66 ms |
7996 KB |
Output is correct |
26 |
Correct |
49 ms |
5152 KB |
Output is correct |
27 |
Correct |
42 ms |
5064 KB |
Output is correct |
28 |
Correct |
78 ms |
8864 KB |
Output is correct |
29 |
Correct |
76 ms |
7916 KB |
Output is correct |
30 |
Correct |
40 ms |
3608 KB |
Output is correct |
31 |
Correct |
80 ms |
8772 KB |
Output is correct |