#include <bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define STL(i, x) for(auto &i:x) cout << i << " "; cout << "\n";
using namespace std;
long long a[200050], b[200050];
long long qx[200050];
void db(){
cout << "\n";
}
template<class T, class ...U>
void db(T XXX, U ...YYY){
cout << XXX; db(YYY...);
}
int main(){
int n, q;
cin >> n;
loop(i,0,n){
cin >> a[i];
b[i] = a[i];
}
cin >> q;
//db("q = ", q);
loop(i,0,q){
cin >> qx[i];
}
int now_i = 0;
long long sum = 0, cnt;
loop(i,0,n){
cnt = 1;
while(!(b[i] & 1)){
b[i] >>= 1;
cnt <<= 1;
}
sum += cnt;
while(true){
if(now_i == q)
return 0;
if(qx[now_i] <= sum){
cout << b[i] << "\n";
now_i++;
}
else break;
}
}
return 0;
}
/*
4
14 9 8 12
6
2 3 5 7 11 13
*/
# |
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 |
43 ms |
3632 KB |
Output is correct |
4 |
Correct |
56 ms |
2484 KB |
Output is correct |
5 |
Correct |
99 ms |
5316 KB |
Output is correct |
6 |
Correct |
64 ms |
3756 KB |
Output is correct |
7 |
Correct |
105 ms |
5456 KB |
Output is correct |
8 |
Correct |
110 ms |
5296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
324 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
2 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 |
43 ms |
3632 KB |
Output is correct |
4 |
Correct |
56 ms |
2484 KB |
Output is correct |
5 |
Correct |
99 ms |
5316 KB |
Output is correct |
6 |
Correct |
64 ms |
3756 KB |
Output is correct |
7 |
Correct |
105 ms |
5456 KB |
Output is correct |
8 |
Correct |
110 ms |
5296 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
324 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
55 ms |
2856 KB |
Output is correct |
24 |
Correct |
89 ms |
4020 KB |
Output is correct |
25 |
Correct |
167 ms |
6872 KB |
Output is correct |
26 |
Correct |
120 ms |
3700 KB |
Output is correct |
27 |
Correct |
103 ms |
3672 KB |
Output is correct |
28 |
Correct |
201 ms |
6236 KB |
Output is correct |
29 |
Correct |
192 ms |
5324 KB |
Output is correct |
30 |
Correct |
93 ms |
2508 KB |
Output is correct |
31 |
Correct |
184 ms |
5852 KB |
Output is correct |