#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 |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
19 ms |
3908 KB |
Output is correct |
4 |
Correct |
29 ms |
2120 KB |
Output is correct |
5 |
Correct |
53 ms |
4932 KB |
Output is correct |
6 |
Correct |
28 ms |
4100 KB |
Output is correct |
7 |
Correct |
51 ms |
5000 KB |
Output is correct |
8 |
Correct |
49 ms |
5440 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 |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
0 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 |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
340 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 |
19 ms |
3908 KB |
Output is correct |
4 |
Correct |
29 ms |
2120 KB |
Output is correct |
5 |
Correct |
53 ms |
4932 KB |
Output is correct |
6 |
Correct |
28 ms |
4100 KB |
Output is correct |
7 |
Correct |
51 ms |
5000 KB |
Output is correct |
8 |
Correct |
49 ms |
5440 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 |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
0 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 |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
27 ms |
2764 KB |
Output is correct |
24 |
Correct |
34 ms |
4816 KB |
Output is correct |
25 |
Correct |
66 ms |
8012 KB |
Output is correct |
26 |
Correct |
46 ms |
5168 KB |
Output is correct |
27 |
Correct |
44 ms |
5060 KB |
Output is correct |
28 |
Correct |
74 ms |
8928 KB |
Output is correct |
29 |
Correct |
77 ms |
8016 KB |
Output is correct |
30 |
Correct |
39 ms |
3616 KB |
Output is correct |
31 |
Correct |
75 ms |
8768 KB |
Output is correct |