#include <bits/stdc++.h>
using namespace std;
#define sz(v) int(v.size())
#define ar array
typedef long long ll;
const int MAXN = 2e5+10, MOD = 1e9+7;
void solve() {
int n; cin >> n;
vector<pair<int, int>> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i].first, a[i].second = 1;
while (a[i].first % 2 == 0) {
a[i].first /= 2;
a[i].second *= 2;
}
}
vector<ll> pre(n);
for (int i = 0; i < n; i++) {
pre[i] = a[i].second;
if (i) pre[i] += pre[i-1];
}
int q; cin >> q;
while (q--) {
ll x; cin >> x;
// find first thing >= x
int p = std::lower_bound(pre.begin(), pre.end(), x) - pre.begin();
cout << a[p].first << '\n';
}
}
int main() {
ios::sync_with_stdio(false); cin.tie(0);
int T=1;
// cin >> T;
while (T--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
20 ms |
3884 KB |
Output is correct |
4 |
Correct |
30 ms |
1972 KB |
Output is correct |
5 |
Correct |
50 ms |
4424 KB |
Output is correct |
6 |
Correct |
28 ms |
3920 KB |
Output is correct |
7 |
Correct |
50 ms |
4452 KB |
Output is correct |
8 |
Correct |
48 ms |
4460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
20 ms |
3884 KB |
Output is correct |
4 |
Correct |
30 ms |
1972 KB |
Output is correct |
5 |
Correct |
50 ms |
4424 KB |
Output is correct |
6 |
Correct |
28 ms |
3920 KB |
Output is correct |
7 |
Correct |
50 ms |
4452 KB |
Output is correct |
8 |
Correct |
48 ms |
4460 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
328 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
27 ms |
2788 KB |
Output is correct |
24 |
Correct |
38 ms |
3908 KB |
Output is correct |
25 |
Correct |
64 ms |
6228 KB |
Output is correct |
26 |
Correct |
57 ms |
3812 KB |
Output is correct |
27 |
Correct |
42 ms |
3656 KB |
Output is correct |
28 |
Correct |
77 ms |
5480 KB |
Output is correct |
29 |
Correct |
73 ms |
4680 KB |
Output is correct |
30 |
Correct |
39 ms |
2260 KB |
Output is correct |
31 |
Correct |
75 ms |
4976 KB |
Output is correct |