//#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#define y2 y_2
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
mt19937 rnd(time(NULL));
const ll mod=998244353;
const int N=610;
const int Lg=16;
void solve(){
int n;cin>>n;
vector<pair<ll,ll> >v;
for (int i=1;i<=n;i++){
ll x;cin>>x;
ll y=1;
while (x%2==0){
y*=2;
x/=2;
}
v.push_back({y,x});
}
int q;cin>>q;
int j=0;
ll sum=0ll;
for (int i=1;i<=q;i++){
ll x;cin>>x;
while (sum<x){
sum+=v[j++].first;
}
cout<<v[j-1].second<<endl;
}
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int tt=1;
// cin>>tt;
while (tt--){
solve();
}
return 0;
}
/**
3
5 2 7 3 1 6 8 4
**/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
20 ms |
4588 KB |
Output is correct |
4 |
Correct |
24 ms |
1756 KB |
Output is correct |
5 |
Correct |
44 ms |
4780 KB |
Output is correct |
6 |
Correct |
26 ms |
4684 KB |
Output is correct |
7 |
Correct |
42 ms |
4620 KB |
Output is correct |
8 |
Correct |
45 ms |
4668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 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 |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
20 ms |
4588 KB |
Output is correct |
4 |
Correct |
24 ms |
1756 KB |
Output is correct |
5 |
Correct |
44 ms |
4780 KB |
Output is correct |
6 |
Correct |
26 ms |
4684 KB |
Output is correct |
7 |
Correct |
42 ms |
4620 KB |
Output is correct |
8 |
Correct |
45 ms |
4668 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
1 ms |
320 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
212 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 |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
380 KB |
Output is correct |
23 |
Correct |
27 ms |
2340 KB |
Output is correct |
24 |
Correct |
32 ms |
4792 KB |
Output is correct |
25 |
Correct |
64 ms |
5700 KB |
Output is correct |
26 |
Correct |
38 ms |
3224 KB |
Output is correct |
27 |
Correct |
49 ms |
4772 KB |
Output is correct |
28 |
Correct |
72 ms |
4932 KB |
Output is correct |
29 |
Correct |
69 ms |
4888 KB |
Output is correct |
30 |
Correct |
36 ms |
1692 KB |
Output is correct |
31 |
Correct |
65 ms |
4712 KB |
Output is correct |