#include <iostream>
#include <algorithm>
using namespace std;
const int nmax = 2e5 + 1;
struct numar {
int val, i;
} ax[nmax];
bool cmp(numar a, numar b) {
return a.val < b.val;
}
int check(int x) {
int cnt = 0;
while(x % 2 == 0) {
cnt ++;
x /= 2;
}
return cnt;
}
int ans[nmax], v[nmax];
int main() {
int n;
cin >> n;
for(int i = 1; i <= n; i ++) {
cin >> v[i];
}
int q;
cin >> q;
for(int i = 1; i <= q; i ++) {
cin >> ax[i].val;
ax[i].i = i;
}
sort(ax + 1, ax + q + 1, cmp);
int curr = 0, ult = 0, an = 1;
for(int i = 1; i <= n; i ++) {
if(an == q + 1) {
break;
}
ult = curr;
curr ++;
ult ++;
int x = check(v[i]);
curr += (1 << x) - 1;
if(ult <= ax[an].val && ax[an].val <= curr) {
ans[ax[an].i] = v[i] / (1 << x);
an ++;
i --;
curr -= (1 << x);
ult --;
}
}
for(int i = 1; i <= q; i ++) {
cout << ans[i] << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
35 ms |
2132 KB |
Output is correct |
4 |
Correct |
50 ms |
3448 KB |
Output is correct |
5 |
Correct |
86 ms |
5484 KB |
Output is correct |
6 |
Correct |
52 ms |
3280 KB |
Output is correct |
7 |
Correct |
85 ms |
5476 KB |
Output is correct |
8 |
Correct |
87 ms |
5504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
312 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
35 ms |
2132 KB |
Output is correct |
4 |
Correct |
50 ms |
3448 KB |
Output is correct |
5 |
Correct |
86 ms |
5484 KB |
Output is correct |
6 |
Correct |
52 ms |
3280 KB |
Output is correct |
7 |
Correct |
85 ms |
5476 KB |
Output is correct |
8 |
Correct |
87 ms |
5504 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
312 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |