#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;
int a[n + 1];
vector<vector<int>> v;
for (int i = 1; i <= n; i++) {
cin >> a[i];
int cnt = 1;
while(a[i] % 2 == 0) {
cnt *= 2;
a[i] /= 2;
}
v.push_back({cnt, a[i]});
}
int pre[n + 3];
pre[0] = 0;
//cout << pre[0] << ' ';
for (int i = 1; i < n; i++) {
pre[i] = pre[i - 1] + v[i - 1][0];
// cout << pre[i] << ' ';
}
//cout << nl;
int q;
cin >> q;
while(q--) {
int x;
cin >> x;
int l = 0, r = n + 1;
while(l + 1 < r) {
int m = (l + r) / 2;
if (x > pre[m]) {
l = m;
} else {
r = m;
}
}
cout << v[l][1] << nl;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
27 ms |
16256 KB |
Output is correct |
4 |
Runtime error |
30 ms |
8756 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
704 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
600 KB |
Output is correct |
6 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
27 ms |
16256 KB |
Output is correct |
4 |
Runtime error |
30 ms |
8756 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |