#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
int N; cin >> N;
vector<pair<int,int>> ans;
for(int i = 0;i<N;++i){
int x; cin >> x;
int y = 1;
while(x % 2 == 0){
x /= 2; y *= 2;
}
ans.push_back({y,x});
//cout << y << " " << x << "\n";
}
//cout << ans[0].first << "\n";
int Q; cin >> Q;
int i = 0; ll cur = 0;
while(Q--){
ll x; cin >> x;
while(i < N && cur+ans[i].first < x){
cur += ans[i].first;
i++;
}
//cout << i-1 << " " << cur << "\n";
cout << ans[i].second << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
71 ms |
2432 KB |
Output is correct |
4 |
Correct |
201 ms |
1008 KB |
Output is correct |
5 |
Correct |
297 ms |
2376 KB |
Output is correct |
6 |
Correct |
141 ms |
2416 KB |
Output is correct |
7 |
Correct |
279 ms |
2376 KB |
Output is correct |
8 |
Correct |
288 ms |
2388 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 |
1 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 |
2 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
2 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
71 ms |
2432 KB |
Output is correct |
4 |
Correct |
201 ms |
1008 KB |
Output is correct |
5 |
Correct |
297 ms |
2376 KB |
Output is correct |
6 |
Correct |
141 ms |
2416 KB |
Output is correct |
7 |
Correct |
279 ms |
2376 KB |
Output is correct |
8 |
Correct |
288 ms |
2388 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 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 |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
2 ms |
212 KB |
Output is correct |
20 |
Correct |
2 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
2 ms |
212 KB |
Output is correct |
23 |
Correct |
164 ms |
1740 KB |
Output is correct |
24 |
Correct |
149 ms |
2452 KB |
Output is correct |
25 |
Correct |
370 ms |
4028 KB |
Output is correct |
26 |
Correct |
192 ms |
1964 KB |
Output is correct |
27 |
Correct |
165 ms |
2432 KB |
Output is correct |
28 |
Correct |
350 ms |
3068 KB |
Output is correct |
29 |
Correct |
345 ms |
2368 KB |
Output is correct |
30 |
Correct |
233 ms |
1308 KB |
Output is correct |
31 |
Correct |
353 ms |
2872 KB |
Output is correct |