#include<bits/stdc++.h>
using namespace std;
#pragma gcc optimize('ofast','unroll-loops')
#define endl '\n'
#define ff first
#define ss second
#define pb emplace_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rep(a,b,c) for(int a=b;a<c;a++)
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
const ll maxn = 100005;
const ll maxm = 200005;
const ll mod = 1000000007;
void solve(){
ll n, q;
ll a; vector<pair<ll,ll>> vc;
cin >> n;
rep(i,0,n){
cin >> a;
rep(i,0,100){
if(a%2){
vc.pb(mp(vc.size()?vc.back().ff+(1ll<<i):(1ll<<i),a));
break;
}else a /= 2;
}
}
cin >> q;
while(q--){
cin >> a;
cout << lower_bound(all(vc),mp(a,0ll))->ss << endl;
}
}
int main(){
//freopen("input.txt","r",stdin);
//freopen("sol.txt","w",stdout);
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t = 1;
//cin >> t;
while(t--) solve();
}
Compilation message
Main.cpp:4: warning: ignoring '#pragma gcc optimize' [-Wunknown-pragmas]
4 | #pragma gcc optimize('ofast','unroll-loops')
|
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
21 ms |
5068 KB |
Output is correct |
4 |
Correct |
34 ms |
2476 KB |
Output is correct |
5 |
Correct |
52 ms |
5624 KB |
Output is correct |
6 |
Correct |
30 ms |
5068 KB |
Output is correct |
7 |
Correct |
51 ms |
5624 KB |
Output is correct |
8 |
Correct |
53 ms |
5864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
292 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
352 KB |
Output is correct |
9 |
Correct |
1 ms |
224 KB |
Output is correct |
10 |
Correct |
1 ms |
224 KB |
Output is correct |
11 |
Correct |
1 ms |
352 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 |
21 ms |
5068 KB |
Output is correct |
4 |
Correct |
34 ms |
2476 KB |
Output is correct |
5 |
Correct |
52 ms |
5624 KB |
Output is correct |
6 |
Correct |
30 ms |
5068 KB |
Output is correct |
7 |
Correct |
51 ms |
5624 KB |
Output is correct |
8 |
Correct |
53 ms |
5864 KB |
Output is correct |
9 |
Correct |
1 ms |
292 KB |
Output is correct |
10 |
Correct |
1 ms |
320 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
352 KB |
Output is correct |
17 |
Correct |
1 ms |
224 KB |
Output is correct |
18 |
Correct |
1 ms |
224 KB |
Output is correct |
19 |
Correct |
1 ms |
352 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 |
29 ms |
3116 KB |
Output is correct |
24 |
Correct |
35 ms |
6064 KB |
Output is correct |
25 |
Correct |
70 ms |
8896 KB |
Output is correct |
26 |
Correct |
43 ms |
5612 KB |
Output is correct |
27 |
Correct |
42 ms |
5972 KB |
Output is correct |
28 |
Correct |
84 ms |
9396 KB |
Output is correct |
29 |
Correct |
77 ms |
8928 KB |
Output is correct |
30 |
Correct |
39 ms |
3880 KB |
Output is correct |
31 |
Correct |
80 ms |
9232 KB |
Output is correct |