#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug if(0)
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin>>n;
vector<ll> a(n), pref(n);
vector<pair<ll, ll>> t;
for(int i=0; i<n; i++) {
cin>>a[i];
int cnt = 1, left = a[i];
while(left%2 == 0) {
cnt<<=1;
left>>=1;
}
t.push_back({left, cnt});
if(i == 0) pref[i] = cnt;
else pref[i] = pref[i-1]+cnt;
}
int q; cin>>q;
while(q--) {
ll x; cin>>x;
int lo = 0, hi = n-1;
while(lo < hi) {
int m = (lo+hi)/2;
if(pref[m] < x) lo = m+1;
else hi = m;
}
if(lo < 0) lo = 0;
cout<<t[lo].first<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
21 ms |
8012 KB |
Output is correct |
4 |
Correct |
27 ms |
3180 KB |
Output is correct |
5 |
Correct |
50 ms |
8764 KB |
Output is correct |
6 |
Correct |
29 ms |
7660 KB |
Output is correct |
7 |
Correct |
48 ms |
8824 KB |
Output is correct |
8 |
Correct |
52 ms |
8876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
0 ms |
320 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
320 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
21 ms |
8012 KB |
Output is correct |
4 |
Correct |
27 ms |
3180 KB |
Output is correct |
5 |
Correct |
50 ms |
8764 KB |
Output is correct |
6 |
Correct |
29 ms |
7660 KB |
Output is correct |
7 |
Correct |
48 ms |
8824 KB |
Output is correct |
8 |
Correct |
52 ms |
8876 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
316 KB |
Output is correct |
11 |
Correct |
0 ms |
320 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
320 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
328 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
25 ms |
3612 KB |
Output is correct |
24 |
Correct |
36 ms |
8228 KB |
Output is correct |
25 |
Correct |
63 ms |
12012 KB |
Output is correct |
26 |
Correct |
43 ms |
7696 KB |
Output is correct |
27 |
Correct |
40 ms |
8232 KB |
Output is correct |
28 |
Correct |
74 ms |
12432 KB |
Output is correct |
29 |
Correct |
70 ms |
12004 KB |
Output is correct |
30 |
Correct |
37 ms |
4216 KB |
Output is correct |
31 |
Correct |
76 ms |
12408 KB |
Output is correct |