#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
#define pb push_back
#define siz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values){
cout << vars << " = ";
string delim = "";
(...,(cout << delim << values, delim = ", "));
cout << endl;
}
const int MOD = 1e9+7;
//==================================
const int MAX = 2e5+5;
ll val[MAX], cnt[MAX];
int main(){
cin.tie(0)->sync_with_stdio(0);
int n; cin >> n; vector<pll> v;
for (int i = 1; i <= n; i++){
ll a; cin >> a;
ll x = 1; while (!(a&1)){ x *= 2, a /= 2;}
cnt[i] = cnt[i-1]+x, val[i] = a;
}
ll curr = 0;
int q; cin >> q;
while (q--){
ll p; cin >> p;
while (cnt[curr] < p) curr++;
cout << val[curr] << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
18 ms |
3924 KB |
Output is correct |
4 |
Correct |
24 ms |
2312 KB |
Output is correct |
5 |
Correct |
45 ms |
5468 KB |
Output is correct |
6 |
Correct |
28 ms |
3996 KB |
Output is correct |
7 |
Correct |
43 ms |
5480 KB |
Output is correct |
8 |
Correct |
43 ms |
5560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 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 |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
18 ms |
3924 KB |
Output is correct |
4 |
Correct |
24 ms |
2312 KB |
Output is correct |
5 |
Correct |
45 ms |
5468 KB |
Output is correct |
6 |
Correct |
28 ms |
3996 KB |
Output is correct |
7 |
Correct |
43 ms |
5480 KB |
Output is correct |
8 |
Correct |
43 ms |
5560 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 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 |
468 KB |
Output is correct |
23 |
Correct |
34 ms |
3040 KB |
Output is correct |
24 |
Correct |
33 ms |
5140 KB |
Output is correct |
25 |
Correct |
61 ms |
8700 KB |
Output is correct |
26 |
Correct |
40 ms |
5484 KB |
Output is correct |
27 |
Correct |
40 ms |
5496 KB |
Output is correct |
28 |
Correct |
78 ms |
9220 KB |
Output is correct |
29 |
Correct |
70 ms |
8780 KB |
Output is correct |
30 |
Correct |
40 ms |
3712 KB |
Output is correct |
31 |
Correct |
71 ms |
9064 KB |
Output is correct |