#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define F first
#define S second
using namespace std;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
const int inf = 1e9;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<int>a(n + 1);
vector<pair<int,int>>pref(n + 1);
for(int i = 1; i <= n; i++) {
cin >> a[i];
int pw = 1;
while(a[i] % (pw * 2) == 0) pw *= 2;
pref[i] = {a[i] / pw,pw};
pref[i].S += pref[i - 1].S;
}
int q;
cin >> q;
while(q--) {
int x;
cin >> x;
int l = 1,r = n,ans = -1;
while(l <= r) {
int mid = (l + r) / 2;
if(pref[mid].S <= x) {
ans = mid;
l = mid + 1;
}else {
r = mid - 1;
}
}
assert(ans != -1);
if(pref[ans].S < x) ans++;
cout << pref[ans].F << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
464 KB |
Output is correct |
2 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |