#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <limits>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
using namespace std;
using ll = long long;
void solve(){
ll n;
cin >> n;
vector<vector<ll>> list_n;
ll curr = 1;
for(ll i = 0; i < n; i++){
ll a;
cin >> a;
ll num = 1;
while(a%2 == 0){
num*=2;
a = (ll)a/2;
}
list_n.push_back({curr, curr + num - 1, a});
curr += num;
}
ll q;
cin >> q;
ll N = list_n.size();
for(ll i = 0; i < q; i++){
ll req;
cin >> req;
ll l = 0;
ll r = N;
while(l + 1 < r){
ll mid = (l + r)/2;
if(list_n[mid][0] > req){
r = mid;
}else if(list_n[mid][1] < req){
l = mid;
}else{
l = mid;
break;
}
}
cout << list_n[l][2] << endl;
}
}
int main(){
ios_base::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
ll t = 1;
//cin >> t;
while(t--){
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
47 ms |
12676 KB |
Output is correct |
4 |
Correct |
140 ms |
4268 KB |
Output is correct |
5 |
Correct |
205 ms |
13304 KB |
Output is correct |
6 |
Correct |
119 ms |
13068 KB |
Output is correct |
7 |
Correct |
197 ms |
13696 KB |
Output is correct |
8 |
Correct |
206 ms |
13560 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 |
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 |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
360 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 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 |
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 |
47 ms |
12676 KB |
Output is correct |
4 |
Correct |
140 ms |
4268 KB |
Output is correct |
5 |
Correct |
205 ms |
13304 KB |
Output is correct |
6 |
Correct |
119 ms |
13068 KB |
Output is correct |
7 |
Correct |
197 ms |
13696 KB |
Output is correct |
8 |
Correct |
206 ms |
13560 KB |
Output is correct |
9 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
360 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 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 |
348 KB |
Output is correct |
23 |
Correct |
122 ms |
4300 KB |
Output is correct |
24 |
Correct |
102 ms |
12928 KB |
Output is correct |
25 |
Correct |
207 ms |
16944 KB |
Output is correct |
26 |
Correct |
122 ms |
10492 KB |
Output is correct |
27 |
Correct |
114 ms |
13772 KB |
Output is correct |
28 |
Correct |
213 ms |
17704 KB |
Output is correct |
29 |
Correct |
211 ms |
16632 KB |
Output is correct |
30 |
Correct |
147 ms |
4700 KB |
Output is correct |
31 |
Correct |
211 ms |
16888 KB |
Output is correct |