#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define pb push_back
const int mxN = (int)2e5+10;
int n, q, x, i, sum, a[mxN];
void solve(){
cin >> n; vector<pair<int,int>> v;
for(int i = 1; i <= n; i++) {
cin >> x; int num = 1;
while(x%2==0) x/=2, num*=2;
v.pb({num,x});
}
cin >> q;
while(q--){
cin >> x;
while(sum+v[i].fi<x) sum+=v[i++].fi;
cout << v[i].se << "\n";
}
}
int32_t main() {
ios_base::sync_with_stdio(false); cin.tie(0);
int t = 1; //cin >> t;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
18 ms |
5088 KB |
Output is correct |
4 |
Correct |
24 ms |
2464 KB |
Output is correct |
5 |
Correct |
41 ms |
5692 KB |
Output is correct |
6 |
Correct |
26 ms |
5004 KB |
Output is correct |
7 |
Correct |
41 ms |
5688 KB |
Output is correct |
8 |
Correct |
41 ms |
5692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 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 |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
380 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
18 ms |
5088 KB |
Output is correct |
4 |
Correct |
24 ms |
2464 KB |
Output is correct |
5 |
Correct |
41 ms |
5692 KB |
Output is correct |
6 |
Correct |
26 ms |
5004 KB |
Output is correct |
7 |
Correct |
41 ms |
5688 KB |
Output is correct |
8 |
Correct |
41 ms |
5692 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 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 |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
380 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
22 ms |
3092 KB |
Output is correct |
24 |
Correct |
30 ms |
6084 KB |
Output is correct |
25 |
Correct |
57 ms |
8932 KB |
Output is correct |
26 |
Correct |
41 ms |
5816 KB |
Output is correct |
27 |
Correct |
38 ms |
6080 KB |
Output is correct |
28 |
Correct |
69 ms |
9272 KB |
Output is correct |
29 |
Correct |
67 ms |
8792 KB |
Output is correct |
30 |
Correct |
35 ms |
3844 KB |
Output is correct |
31 |
Correct |
72 ms |
9276 KB |
Output is correct |