#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve()
{
int n;
cin >> n;
vector<int> v(n);
for (int &i : v)
cin >> i;
vector<int> a = v, b(n, 1);
for (int i = 0; i < n; ++i)
while (a[i] % 2 == 0)
b[i] *= 2, a[i] /= 2;
for (int i = 1; i < n; ++i)
b[i] += b[i - 1];
int q;
cin >> q;
while (q--)
{
int x;
cin >> x;
int id = lower_bound(b.begin(), b.end(), x) - b.begin();
cout << a[id] << '\n';
}
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
19 ms |
5672 KB |
Output is correct |
4 |
Correct |
25 ms |
2652 KB |
Output is correct |
5 |
Correct |
44 ms |
7248 KB |
Output is correct |
6 |
Correct |
26 ms |
5460 KB |
Output is correct |
7 |
Correct |
44 ms |
7208 KB |
Output is correct |
8 |
Correct |
44 ms |
7128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
456 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
19 ms |
5672 KB |
Output is correct |
4 |
Correct |
25 ms |
2652 KB |
Output is correct |
5 |
Correct |
44 ms |
7248 KB |
Output is correct |
6 |
Correct |
26 ms |
5460 KB |
Output is correct |
7 |
Correct |
44 ms |
7208 KB |
Output is correct |
8 |
Correct |
44 ms |
7128 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
456 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
26 ms |
3428 KB |
Output is correct |
24 |
Correct |
31 ms |
6484 KB |
Output is correct |
25 |
Correct |
58 ms |
10292 KB |
Output is correct |
26 |
Correct |
47 ms |
6484 KB |
Output is correct |
27 |
Correct |
36 ms |
6796 KB |
Output is correct |
28 |
Correct |
65 ms |
10712 KB |
Output is correct |
29 |
Correct |
63 ms |
10344 KB |
Output is correct |
30 |
Correct |
31 ms |
4056 KB |
Output is correct |
31 |
Correct |
65 ms |
10628 KB |
Output is correct |