#include<bits/stdc++.h>
using namespace std;
#define int long long
constexpr int sz = 2e5 + 5;
int n, a[sz], Q, x;
vector<array<int, 2>> em;
signed main(){
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> n;
for(register int i = 1; i <= n; ++i){
cin >> a[i];
}
for(register int i = 1; i <= n; ++i){
long long cnt(1);
while(a[i] % 2 == 0){
cnt <<= 1LL;
a[i] >>= 1LL;
}
em.emplace_back(array<int, 2>{cnt, a[i]});
}
int sm(0), l(-1);
cin >> Q;
while(Q--){
cin >> x;
while(sm < x){
++l, sm += em[l][0];
}
cout << em[l][1] << '\n';
}
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:15:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
15 | for(register int i = 1; i <= n; ++i){
| ^
Main.cpp:19:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
19 | for(register int i = 1; i <= n; ++i){
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
18 ms |
7380 KB |
Output is correct |
4 |
Correct |
21 ms |
2776 KB |
Output is correct |
5 |
Correct |
36 ms |
8400 KB |
Output is correct |
6 |
Correct |
22 ms |
7888 KB |
Output is correct |
7 |
Correct |
36 ms |
8660 KB |
Output is correct |
8 |
Correct |
36 ms |
6916 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
18 ms |
7380 KB |
Output is correct |
4 |
Correct |
21 ms |
2776 KB |
Output is correct |
5 |
Correct |
36 ms |
8400 KB |
Output is correct |
6 |
Correct |
22 ms |
7888 KB |
Output is correct |
7 |
Correct |
36 ms |
8660 KB |
Output is correct |
8 |
Correct |
36 ms |
6916 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 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 |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
480 KB |
Output is correct |
23 |
Correct |
19 ms |
3544 KB |
Output is correct |
24 |
Correct |
27 ms |
7888 KB |
Output is correct |
25 |
Correct |
47 ms |
10432 KB |
Output is correct |
26 |
Correct |
31 ms |
6868 KB |
Output is correct |
27 |
Correct |
30 ms |
7636 KB |
Output is correct |
28 |
Correct |
66 ms |
11200 KB |
Output is correct |
29 |
Correct |
51 ms |
10532 KB |
Output is correct |
30 |
Correct |
30 ms |
4048 KB |
Output is correct |
31 |
Correct |
55 ms |
11300 KB |
Output is correct |