#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define ep emplace
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
const ll INF=1e18;
const ll mod=1e9+7;
int main()
{
ios::sync_with_stdio(false); cin.tie(NULL);
int n, q; cin >> n;
vector<pl> v;
for(int i=0;i<n;i++)
{
int a; cin >> a;
ll cnt=1;
while(a%2==0) a/=2, cnt*=2;
v.eb(cnt, a);
}
ll i=0, sum=0;
cin >> q;
while(q--)
{
ll x; cin >> x;
while(i<n and sum+v[i].fi<x) sum+=v[i].fi, i++;
cout << v[i].se << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
19 ms |
5028 KB |
Output is correct |
4 |
Correct |
25 ms |
2404 KB |
Output is correct |
5 |
Correct |
42 ms |
5656 KB |
Output is correct |
6 |
Correct |
25 ms |
5068 KB |
Output is correct |
7 |
Correct |
46 ms |
5632 KB |
Output is correct |
8 |
Correct |
41 ms |
5736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 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 |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
328 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
19 ms |
5028 KB |
Output is correct |
4 |
Correct |
25 ms |
2404 KB |
Output is correct |
5 |
Correct |
42 ms |
5656 KB |
Output is correct |
6 |
Correct |
25 ms |
5068 KB |
Output is correct |
7 |
Correct |
46 ms |
5632 KB |
Output is correct |
8 |
Correct |
41 ms |
5736 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 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 |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
328 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 |
23 ms |
3148 KB |
Output is correct |
24 |
Correct |
32 ms |
6048 KB |
Output is correct |
25 |
Correct |
58 ms |
8856 KB |
Output is correct |
26 |
Correct |
39 ms |
5688 KB |
Output is correct |
27 |
Correct |
37 ms |
6052 KB |
Output is correct |
28 |
Correct |
67 ms |
9256 KB |
Output is correct |
29 |
Correct |
68 ms |
8824 KB |
Output is correct |
30 |
Correct |
35 ms |
3828 KB |
Output is correct |
31 |
Correct |
70 ms |
9296 KB |
Output is correct |