#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n;
cin>>n;
vector<pair<ll,ll>>a(n);
vector<ll>tot(n);
ll cur=0;
for(ll i=0;i<n;i++){
cin>>a[i].ff;
a[i].ss=1;
while(a[i].ff%2==0){
a[i].ff/=2;
a[i].ss*=2;
}
cur+=a[i].ss;
tot[i]=cur;
}
ll q;
cin>>q;
while(q--){
ll x;
cin>>x;
ll y=lower_bound(all(tot),x)-tot.begin();
cout<<a[y].ff<<"\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
16 ms |
5476 KB |
Output is correct |
4 |
Correct |
22 ms |
2644 KB |
Output is correct |
5 |
Correct |
38 ms |
7228 KB |
Output is correct |
6 |
Correct |
23 ms |
5464 KB |
Output is correct |
7 |
Correct |
39 ms |
7248 KB |
Output is correct |
8 |
Correct |
37 ms |
7252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 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 |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
464 KB |
Output is correct |
9 |
Correct |
0 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
348 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 |
464 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 |
5476 KB |
Output is correct |
4 |
Correct |
22 ms |
2644 KB |
Output is correct |
5 |
Correct |
38 ms |
7228 KB |
Output is correct |
6 |
Correct |
23 ms |
5464 KB |
Output is correct |
7 |
Correct |
39 ms |
7248 KB |
Output is correct |
8 |
Correct |
37 ms |
7252 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 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 |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
464 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
0 ms |
348 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 |
464 KB |
Output is correct |
23 |
Correct |
21 ms |
3284 KB |
Output is correct |
24 |
Correct |
27 ms |
6492 KB |
Output is correct |
25 |
Correct |
50 ms |
10520 KB |
Output is correct |
26 |
Correct |
34 ms |
6668 KB |
Output is correct |
27 |
Correct |
31 ms |
6612 KB |
Output is correct |
28 |
Correct |
57 ms |
10844 KB |
Output is correct |
29 |
Correct |
58 ms |
10424 KB |
Output is correct |
30 |
Correct |
29 ms |
3932 KB |
Output is correct |
31 |
Correct |
58 ms |
10836 KB |
Output is correct |