#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define ln '\n'
const int N = 2e5 + 5;
ll n, a[N];
vector<ll> pfx, val;
void solve(){
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
pfx.push_back(0);
val.push_back(-1);
for (int i = 0; i < n; i++){
int cnt = 0;
ll x = a[i];
while (x % 2 == 0) {cnt++; x /= 2;}
pfx.push_back((1LL << cnt));
val.push_back(x);
// cout << cnt << ' ' << x << ln;
}
for (int i = 1; i < (int)pfx.size(); i++) pfx[i] += pfx[i-1];
int q; cin >> q;
while (q--){
ll x; cin >> x;
int j = lower_bound(pfx.begin(), pfx.end(), x) - pfx.begin();
cout << val[j] << ln;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// int TT; cin >> TT;
// while (TT--) {solve();}
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
13 ms |
5860 KB |
Output is correct |
4 |
Correct |
16 ms |
3008 KB |
Output is correct |
5 |
Correct |
33 ms |
7356 KB |
Output is correct |
6 |
Correct |
30 ms |
5576 KB |
Output is correct |
7 |
Correct |
29 ms |
7360 KB |
Output is correct |
8 |
Correct |
53 ms |
7476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
600 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
480 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
520 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
13 ms |
5860 KB |
Output is correct |
4 |
Correct |
16 ms |
3008 KB |
Output is correct |
5 |
Correct |
33 ms |
7356 KB |
Output is correct |
6 |
Correct |
30 ms |
5576 KB |
Output is correct |
7 |
Correct |
29 ms |
7360 KB |
Output is correct |
8 |
Correct |
53 ms |
7476 KB |
Output is correct |
9 |
Correct |
1 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 |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
480 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
520 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
18 ms |
3544 KB |
Output is correct |
24 |
Correct |
38 ms |
6644 KB |
Output is correct |
25 |
Correct |
37 ms |
10672 KB |
Output is correct |
26 |
Correct |
26 ms |
6844 KB |
Output is correct |
27 |
Correct |
25 ms |
7104 KB |
Output is correct |
28 |
Correct |
51 ms |
10960 KB |
Output is correct |
29 |
Correct |
50 ms |
10412 KB |
Output is correct |
30 |
Correct |
23 ms |
4296 KB |
Output is correct |
31 |
Correct |
44 ms |
10932 KB |
Output is correct |