//JOI 2022 Final Round
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n);
for(int i=0; i<n; i++){
cin >> a[i];
}
int q;
cin >> q;
int cnt=0;
int length=0;
int j=0;
for(int i=0; i<q; i++){
int x;
cin >> x;
while(cnt<x){
int anz=1;
while(a[j]%2==0){
anz*=2;
a[j]/=2;
}
cnt+=anz;
length=a[j];
j++;
}
cout << length << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
14 ms |
2504 KB |
Output is correct |
4 |
Correct |
20 ms |
1932 KB |
Output is correct |
5 |
Correct |
35 ms |
3992 KB |
Output is correct |
6 |
Correct |
20 ms |
2744 KB |
Output is correct |
7 |
Correct |
34 ms |
3924 KB |
Output is correct |
8 |
Correct |
33 ms |
4088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
320 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 |
324 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
14 ms |
2504 KB |
Output is correct |
4 |
Correct |
20 ms |
1932 KB |
Output is correct |
5 |
Correct |
35 ms |
3992 KB |
Output is correct |
6 |
Correct |
20 ms |
2744 KB |
Output is correct |
7 |
Correct |
34 ms |
3924 KB |
Output is correct |
8 |
Correct |
33 ms |
4088 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
316 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
320 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
320 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 |
324 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
328 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
19 ms |
2768 KB |
Output is correct |
24 |
Correct |
24 ms |
4104 KB |
Output is correct |
25 |
Correct |
46 ms |
7236 KB |
Output is correct |
26 |
Correct |
32 ms |
4576 KB |
Output is correct |
27 |
Correct |
29 ms |
4440 KB |
Output is correct |
28 |
Correct |
58 ms |
7568 KB |
Output is correct |
29 |
Correct |
52 ms |
7128 KB |
Output is correct |
30 |
Correct |
27 ms |
3548 KB |
Output is correct |
31 |
Correct |
57 ms |
7576 KB |
Output is correct |