#include<bits/stdc++.h>
#define ft first
#define sd second
#define pb push_back
#define nl "\n"
#define int ll
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;
const int N = 2000;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T = 1;
while(T--) {
int n;
cin >> n;
vector<vector<int>> v;
for (int i = 1; i <= n; i++) {
int a;
cin >> a;
int cnt = 1;
while(a % 2 == 0) {
cnt *= 2;
a /= 2;
}
v.push_back({cnt, a});
}
int pre[n + 3];
pre[0] = 0;
for (int i = 1; i < n; i++) {
pre[i] = pre[i - 1] + v[i - 1][0];
}
int q;
cin >> q;
while(q--) {
int x;
cin >> x;
int l = 0, r = n;
while(l + 1 < r) {
int m = (l + r) / 2;
if (x > pre[m]) {
l = m;
} else {
r = m;
}
}
cout << v[l][1] << nl;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
29 ms |
13860 KB |
Output is correct |
4 |
Correct |
26 ms |
3600 KB |
Output is correct |
5 |
Correct |
50 ms |
14940 KB |
Output is correct |
6 |
Correct |
35 ms |
12300 KB |
Output is correct |
7 |
Correct |
52 ms |
16176 KB |
Output is correct |
8 |
Correct |
49 ms |
15352 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 |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
360 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
29 ms |
13860 KB |
Output is correct |
4 |
Correct |
26 ms |
3600 KB |
Output is correct |
5 |
Correct |
50 ms |
14940 KB |
Output is correct |
6 |
Correct |
35 ms |
12300 KB |
Output is correct |
7 |
Correct |
52 ms |
16176 KB |
Output is correct |
8 |
Correct |
49 ms |
15352 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 |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
600 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
360 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
604 KB |
Output is correct |
23 |
Correct |
23 ms |
4628 KB |
Output is correct |
24 |
Correct |
35 ms |
13580 KB |
Output is correct |
25 |
Correct |
66 ms |
19444 KB |
Output is correct |
26 |
Correct |
46 ms |
11612 KB |
Output is correct |
27 |
Correct |
40 ms |
12540 KB |
Output is correct |
28 |
Correct |
75 ms |
18936 KB |
Output is correct |
29 |
Correct |
67 ms |
18088 KB |
Output is correct |
30 |
Correct |
33 ms |
4876 KB |
Output is correct |
31 |
Correct |
72 ms |
18884 KB |
Output is correct |