#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n;
vector<pair<long long,long long>>arr;
for (int i = 0;i<n;++i){
long long x;cin>>x;
int counts = 1;
while(x % 2 == 0){
x/=2;
counts*=2;
}
if (!arr.empty()){
if (arr.back().first == x){
arr.back().second+=counts;
}
else{
arr.push_back({x,counts});
}
}
else{
arr.push_back({x,counts});
}
}
int m = (int)arr.size();
vector<long long>pref(m + 1,0);
for (int i = 0;i<m;++i){
pref[i + 1] = pref[i] + arr[i].second;
}
int q;cin>>q;
for (int i = 0;i<q;++i){
long long x;cin>>x;
int temp = lower_bound(pref.begin(),pref.end(),x) - pref.begin();
cout<<arr[temp - 1].first<<'\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
22 ms |
3916 KB |
Output is correct |
4 |
Correct |
29 ms |
2260 KB |
Output is correct |
5 |
Correct |
49 ms |
5472 KB |
Output is correct |
6 |
Correct |
28 ms |
3396 KB |
Output is correct |
7 |
Correct |
48 ms |
4668 KB |
Output is correct |
8 |
Correct |
40 ms |
2508 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 |
0 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 |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 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 |
340 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 |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
22 ms |
3916 KB |
Output is correct |
4 |
Correct |
29 ms |
2260 KB |
Output is correct |
5 |
Correct |
49 ms |
5472 KB |
Output is correct |
6 |
Correct |
28 ms |
3396 KB |
Output is correct |
7 |
Correct |
48 ms |
4668 KB |
Output is correct |
8 |
Correct |
40 ms |
2508 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 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 |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 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 |
340 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 |
28 ms |
3272 KB |
Output is correct |
24 |
Correct |
36 ms |
6336 KB |
Output is correct |
25 |
Correct |
76 ms |
10380 KB |
Output is correct |
26 |
Correct |
45 ms |
6576 KB |
Output is correct |
27 |
Correct |
46 ms |
6616 KB |
Output is correct |
28 |
Correct |
96 ms |
10756 KB |
Output is correct |
29 |
Correct |
68 ms |
5460 KB |
Output is correct |
30 |
Correct |
39 ms |
3780 KB |
Output is correct |
31 |
Correct |
82 ms |
10004 KB |
Output is correct |