#include <bits/stdc++.h>
#define int long long
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
using namespace std;
signed main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int n; cin >>n;
vector<int> a(n);
vector<int> sze(n,1);
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++)
{
while(a[i]%2==0) {
sze[i]*=2;
a[i]=a[i]/2;
}
if(i>0) sze[i]+=sze[i-1];
}
int q; cin >> q;
while(q--){
int x; cin >> x;
int ans=lower_bound(sze.begin(),sze.end(),x)-sze.begin();
cout << a[ans] << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
16 ms |
4048 KB |
Output is correct |
4 |
Correct |
22 ms |
2396 KB |
Output is correct |
5 |
Correct |
39 ms |
5484 KB |
Output is correct |
6 |
Correct |
23 ms |
4188 KB |
Output is correct |
7 |
Correct |
38 ms |
5468 KB |
Output is correct |
8 |
Correct |
43 ms |
5596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 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 |
360 KB |
Output is correct |
13 |
Correct |
1 ms |
344 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 |
16 ms |
4048 KB |
Output is correct |
4 |
Correct |
22 ms |
2396 KB |
Output is correct |
5 |
Correct |
39 ms |
5484 KB |
Output is correct |
6 |
Correct |
23 ms |
4188 KB |
Output is correct |
7 |
Correct |
38 ms |
5468 KB |
Output is correct |
8 |
Correct |
43 ms |
5596 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 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 |
360 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
20 ms |
3016 KB |
Output is correct |
24 |
Correct |
26 ms |
5212 KB |
Output is correct |
25 |
Correct |
50 ms |
8944 KB |
Output is correct |
26 |
Correct |
34 ms |
5712 KB |
Output is correct |
27 |
Correct |
33 ms |
5712 KB |
Output is correct |
28 |
Correct |
59 ms |
9360 KB |
Output is correct |
29 |
Correct |
59 ms |
8668 KB |
Output is correct |
30 |
Correct |
29 ms |
3672 KB |
Output is correct |
31 |
Correct |
59 ms |
9296 KB |
Output is correct |