#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int N; cin >> N;
vector<pair<int,int>> res;
for(int i = 0;i<N;++i){
int x; cin >> x;
int p = 1;
while(x % 2 == 0){
x /= 2; p *= 2;
}
res.push_back({p,x});
}
int Q; cin >> Q;
ll sum = 0; int cur = 0;
while(Q--){
ll x; cin >> x;
while(sum+res[cur].first < x && cur < N){
sum += res[cur].first; cur++;
}
cout << res[cur].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 |
16 ms |
3024 KB |
Output is correct |
4 |
Correct |
22 ms |
2056 KB |
Output is correct |
5 |
Correct |
38 ms |
4128 KB |
Output is correct |
6 |
Correct |
23 ms |
2948 KB |
Output is correct |
7 |
Correct |
38 ms |
4036 KB |
Output is correct |
8 |
Correct |
45 ms |
4244 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 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 |
320 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
340 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 |
16 ms |
3024 KB |
Output is correct |
4 |
Correct |
22 ms |
2056 KB |
Output is correct |
5 |
Correct |
38 ms |
4128 KB |
Output is correct |
6 |
Correct |
23 ms |
2948 KB |
Output is correct |
7 |
Correct |
38 ms |
4036 KB |
Output is correct |
8 |
Correct |
45 ms |
4244 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 |
1 ms |
316 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 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 |
320 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
324 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
21 ms |
2908 KB |
Output is correct |
24 |
Correct |
27 ms |
4248 KB |
Output is correct |
25 |
Correct |
51 ms |
7272 KB |
Output is correct |
26 |
Correct |
42 ms |
4696 KB |
Output is correct |
27 |
Correct |
31 ms |
4604 KB |
Output is correct |
28 |
Correct |
58 ms |
7780 KB |
Output is correct |
29 |
Correct |
57 ms |
7224 KB |
Output is correct |
30 |
Correct |
32 ms |
3600 KB |
Output is correct |
31 |
Correct |
64 ms |
7704 KB |
Output is correct |