//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//#pragma pack(1)
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define int long long
#define pii pair<int,int>
#define x first
#define y second
#define N 200015
using namespace std;
//using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset;
//typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set;
int n,arr[N],s[N];
signed main(){
fast
cin>>n;
for (int i=1;i<=n;i++){
cin>>arr[i];
s[i]=1;
while (arr[i]%2==0){
s[i]*=2;
arr[i]/=2;
}
}
int np=1,total=s[1],q; cin>>q;
while (q--){
int x; cin>>x;
while (np<=n&&total<x){
np++;
total+=s[np];
}
cout<<arr[np]<<'\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
25 ms |
3968 KB |
Output is correct |
4 |
Correct |
32 ms |
2352 KB |
Output is correct |
5 |
Correct |
46 ms |
5512 KB |
Output is correct |
6 |
Correct |
25 ms |
4032 KB |
Output is correct |
7 |
Correct |
49 ms |
5540 KB |
Output is correct |
8 |
Correct |
48 ms |
5648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
1 ms |
332 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 |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
25 ms |
3968 KB |
Output is correct |
4 |
Correct |
32 ms |
2352 KB |
Output is correct |
5 |
Correct |
46 ms |
5512 KB |
Output is correct |
6 |
Correct |
25 ms |
4032 KB |
Output is correct |
7 |
Correct |
49 ms |
5540 KB |
Output is correct |
8 |
Correct |
48 ms |
5648 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
332 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 |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
372 KB |
Output is correct |
23 |
Correct |
27 ms |
2964 KB |
Output is correct |
24 |
Correct |
30 ms |
5188 KB |
Output is correct |
25 |
Correct |
59 ms |
8708 KB |
Output is correct |
26 |
Correct |
41 ms |
5448 KB |
Output is correct |
27 |
Correct |
41 ms |
5564 KB |
Output is correct |
28 |
Correct |
78 ms |
9180 KB |
Output is correct |
29 |
Correct |
80 ms |
8644 KB |
Output is correct |
30 |
Correct |
39 ms |
3652 KB |
Output is correct |
31 |
Correct |
72 ms |
9060 KB |
Output is correct |