#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int N; cin >> N;
vector<pair<int,int>> arr;
for(int i = 0;i<N;++i){
int x; cin >> x;
int p = 1;
while(x % 2 == 0){
x /= 2; p *= 2;
}
arr.push_back({x,p});
//cout << x << " " << p << "\n";
}
int Q; cin >> Q;
int pos = 0, cur = 0;
for(int i = 0;i<Q;++i){
int a; cin >> a;
while(cur+arr[pos].second < a){
cur += arr[pos].second;
pos++;
}
cout << arr[pos].first << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
17 ms |
6788 KB |
Output is correct |
4 |
Correct |
20 ms |
2516 KB |
Output is correct |
5 |
Correct |
35 ms |
5844 KB |
Output is correct |
6 |
Correct |
21 ms |
6612 KB |
Output is correct |
7 |
Correct |
35 ms |
7124 KB |
Output is correct |
8 |
Correct |
39 ms |
6356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
452 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
476 KB |
Output is correct |
9 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
464 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 |
17 ms |
6788 KB |
Output is correct |
4 |
Correct |
20 ms |
2516 KB |
Output is correct |
5 |
Correct |
35 ms |
5844 KB |
Output is correct |
6 |
Correct |
21 ms |
6612 KB |
Output is correct |
7 |
Correct |
35 ms |
7124 KB |
Output is correct |
8 |
Correct |
39 ms |
6356 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 |
0 ms |
452 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
476 KB |
Output is correct |
17 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
464 KB |
Output is correct |
23 |
Correct |
19 ms |
3244 KB |
Output is correct |
24 |
Correct |
26 ms |
7892 KB |
Output is correct |
25 |
Correct |
47 ms |
8684 KB |
Output is correct |
26 |
Correct |
33 ms |
5324 KB |
Output is correct |
27 |
Correct |
30 ms |
6088 KB |
Output is correct |
28 |
Correct |
56 ms |
8892 KB |
Output is correct |
29 |
Correct |
52 ms |
8188 KB |
Output is correct |
30 |
Correct |
33 ms |
4000 KB |
Output is correct |
31 |
Correct |
55 ms |
8636 KB |
Output is correct |