#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
int n; cin >> n; vector<int> v(n), w(n+1); w[0] = 1;
for(int i=0;i<n;i++) {
cin >> v[i]; int s = 1;
while((v[i]/s)%2 == 0) s *= 2;
w[i+1] = s+w[i];
}
int q; cin >> q;
while(q--) {
int x; cin >> x;
int y = v[upper_bound(begin(w),end(w),x)-w.begin()-1];
while(!(y%2)) y /= 2;
cout << y << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
66 ms |
4124 KB |
Output is correct |
4 |
Correct |
198 ms |
2360 KB |
Output is correct |
5 |
Correct |
292 ms |
5496 KB |
Output is correct |
6 |
Correct |
141 ms |
4024 KB |
Output is correct |
7 |
Correct |
277 ms |
5460 KB |
Output is correct |
8 |
Correct |
288 ms |
5636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
444 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
66 ms |
4124 KB |
Output is correct |
4 |
Correct |
198 ms |
2360 KB |
Output is correct |
5 |
Correct |
292 ms |
5496 KB |
Output is correct |
6 |
Correct |
141 ms |
4024 KB |
Output is correct |
7 |
Correct |
277 ms |
5460 KB |
Output is correct |
8 |
Correct |
288 ms |
5636 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
444 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
163 ms |
2992 KB |
Output is correct |
24 |
Correct |
167 ms |
5200 KB |
Output is correct |
25 |
Correct |
325 ms |
8788 KB |
Output is correct |
26 |
Correct |
193 ms |
5460 KB |
Output is correct |
27 |
Correct |
166 ms |
5460 KB |
Output is correct |
28 |
Correct |
355 ms |
9300 KB |
Output is correct |
29 |
Correct |
348 ms |
8784 KB |
Output is correct |
30 |
Correct |
239 ms |
3664 KB |
Output is correct |
31 |
Correct |
360 ms |
9044 KB |
Output is correct |