#include<bits/stdc++.h>
#define forn(i,n) for(int i = 0;i < (n);i++)
#define Forn(i,n) for(int i = 1;i <= (n);i++)
#define all(p) p.begin(),p.end()
#define pb push_back
#define F first
#define S second
#define rz resize
#define sz(x) x.size()
#define int long long
#define vi vector<int>
#define pii pair<int,int>
using namespace std;
const int N = 2e5+9;
int n;
pii broke(int x){
int cnt = 1;
while(x % 2 == 0){
x /= 2;
cnt *= 2;
}
return (pii){x,cnt};
}
void solve(){
cin >> n;
vi a(n);
forn(i,n) cin >> a[i];
int q;
vector<pii> b(n+1);
Forn(i,n){
b[i] = broke(a[i-1]);
}
Forn(i,n){
if(i) b[i].S += b[i-1].S;
}
cin >> q;
while(q--){
int c;
cin >> c;
int lo = 0,hi = n;
while(lo != hi-1){
int mid = (lo + hi)/2;
if(b[mid].S < c) lo = mid;
else hi = mid;
}
cout << b[lo + 1].F << '\n';
}
}
signed main(){
cin.tie(NULL);
cout.tie(NULL);
ios_base::sync_with_stdio(0);
solve();
return 0;
}
# |
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 |
22 ms |
5516 KB |
Output is correct |
4 |
Correct |
31 ms |
2440 KB |
Output is correct |
5 |
Correct |
52 ms |
6088 KB |
Output is correct |
6 |
Correct |
33 ms |
5216 KB |
Output is correct |
7 |
Correct |
73 ms |
6100 KB |
Output is correct |
8 |
Correct |
58 ms |
6060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 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 |
316 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 |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
328 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 |
22 ms |
5516 KB |
Output is correct |
4 |
Correct |
31 ms |
2440 KB |
Output is correct |
5 |
Correct |
52 ms |
6088 KB |
Output is correct |
6 |
Correct |
33 ms |
5216 KB |
Output is correct |
7 |
Correct |
73 ms |
6100 KB |
Output is correct |
8 |
Correct |
58 ms |
6060 KB |
Output is correct |
9 |
Correct |
0 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 |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 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 |
316 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 |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
328 KB |
Output is correct |
23 |
Correct |
29 ms |
2888 KB |
Output is correct |
24 |
Correct |
35 ms |
5172 KB |
Output is correct |
25 |
Correct |
70 ms |
7612 KB |
Output is correct |
26 |
Correct |
48 ms |
4660 KB |
Output is correct |
27 |
Correct |
43 ms |
4804 KB |
Output is correct |
28 |
Correct |
89 ms |
6940 KB |
Output is correct |
29 |
Correct |
97 ms |
5972 KB |
Output is correct |
30 |
Correct |
41 ms |
2204 KB |
Output is correct |
31 |
Correct |
83 ms |
6484 KB |
Output is correct |