#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<ll, ll>
typedef long long ll;
const ll MOD = 1000000007LL;
const ll INF = 1e15;
using namespace std;
ll n, q, a[200010], x, sum[200010];
ll l, r, mid;
int main() {
cin.tie(0); cout.tie(0);
ios::sync_with_stdio(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum[i] = a[i]&(-a[i]);
a[i] /= a[i]&(-a[i]);
sum[i] += sum[i-1];
}
cin >> q;
while (q--) {
cin >> x;
l = 1, r = n;
while (l < r) {
mid = (l+r)/2;
if (sum[mid] < x) l = mid+1;
else r = mid;
}
cout << a[r] << "\n";
}
return 0;
}
/*
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
12 ms |
4188 KB |
Output is correct |
4 |
Correct |
19 ms |
3928 KB |
Output is correct |
5 |
Correct |
32 ms |
5460 KB |
Output is correct |
6 |
Correct |
19 ms |
4444 KB |
Output is correct |
7 |
Correct |
32 ms |
5556 KB |
Output is correct |
8 |
Correct |
32 ms |
5784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2412 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
12 ms |
4188 KB |
Output is correct |
4 |
Correct |
19 ms |
3928 KB |
Output is correct |
5 |
Correct |
32 ms |
5460 KB |
Output is correct |
6 |
Correct |
19 ms |
4444 KB |
Output is correct |
7 |
Correct |
32 ms |
5556 KB |
Output is correct |
8 |
Correct |
32 ms |
5784 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2412 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
0 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
18 ms |
4864 KB |
Output is correct |
24 |
Correct |
25 ms |
5724 KB |
Output is correct |
25 |
Correct |
43 ms |
8784 KB |
Output is correct |
26 |
Correct |
28 ms |
6236 KB |
Output is correct |
27 |
Correct |
28 ms |
5972 KB |
Output is correct |
28 |
Correct |
47 ms |
9188 KB |
Output is correct |
29 |
Correct |
46 ms |
8680 KB |
Output is correct |
30 |
Correct |
28 ms |
5720 KB |
Output is correct |
31 |
Correct |
49 ms |
9044 KB |
Output is correct |