#include <bits/stdc++.h>
#define pii pair<ll, ll>
#define ll long long
#define ld long double
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<ll> arr(n + 1);
for (int i = 1; i <= n; i++)
cin >> arr[i];
vector<pii> pref(n + 1, pii(0, 0));
for (int i = 1; i <= n; i++) {
pref[i] = pii(arr[i], 1);
while (pref[i].first % 2 == 0)
pref[i].first /= 2, pref[i].second *= 2;
pref[i].second += pref[i - 1].second;
}
int q;
cin >> q;
while (q--) {
ll s;
cin >> s;
int l = 1, r = n;
while (l < r) {
int mid = (l + r) / 2;
if (pref[mid].second < s)
l = mid + 1;
else
r = mid;
}
cout << pref[l].first << "\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
23 ms |
4848 KB |
Output is correct |
4 |
Correct |
34 ms |
1728 KB |
Output is correct |
5 |
Correct |
52 ms |
5452 KB |
Output is correct |
6 |
Correct |
28 ms |
4388 KB |
Output is correct |
7 |
Correct |
52 ms |
5408 KB |
Output is correct |
8 |
Correct |
54 ms |
5308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
0 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 |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 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 |
256 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
23 ms |
4848 KB |
Output is correct |
4 |
Correct |
34 ms |
1728 KB |
Output is correct |
5 |
Correct |
52 ms |
5452 KB |
Output is correct |
6 |
Correct |
28 ms |
4388 KB |
Output is correct |
7 |
Correct |
52 ms |
5408 KB |
Output is correct |
8 |
Correct |
54 ms |
5308 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 |
0 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 |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
256 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
42 ms |
2204 KB |
Output is correct |
24 |
Correct |
34 ms |
4428 KB |
Output is correct |
25 |
Correct |
70 ms |
6884 KB |
Output is correct |
26 |
Correct |
44 ms |
3916 KB |
Output is correct |
27 |
Correct |
44 ms |
4124 KB |
Output is correct |
28 |
Correct |
90 ms |
6124 KB |
Output is correct |
29 |
Correct |
82 ms |
5368 KB |
Output is correct |
30 |
Correct |
47 ms |
1500 KB |
Output is correct |
31 |
Correct |
82 ms |
5876 KB |
Output is correct |