#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '[' << #x << " is: " << x << "] " << endl;
#define inF freopen("cardgame.in" , "r" , stdin);
#define outF freopen("cardgame.out" , "w" , stdout);
#define imod(a , n) (a % n + n ) % n
#define sor(v) sort(v.begin() , v.end());
#define print(v) for(auto f : v ) cout << f << " " ;
#define rsor(v) sort(v.rbegin() , v.rend());
#define rev(v) reverse(v.begin() , v.end());
#define scan(v)for(auto &it : v)cin >> it ;
#define ll long long
#define logar(x , y) log(x) / log(y)
#define __sum(n) n * (n + 1) / 2
#define __lcm(a , b) a / __gcd(a , b) * b
#define pii pair<int , int >
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
//#define int ll
const int N = 3e5 + 3, M = N * 4 , MX = 2e4 + 40;
const ll MOD = 998244353 , oo = 1e9 + 9 , OO = 1e18 , mod = MOD ;
const double pi = acos(-1) , eps = 1e-17 ;
int di[] = {1 , -1 , 0 , 0};
int dj[] = {0 , 0 , 1 , -1};
int32_t main()
{
// inF;
// inF;outF;
fastio;
//Welcome back without <TAWJIHI>
int n;
cin >> n;
vector<pair<ll , int > > v;
while(n--){
ll a ;
cin >> a ;
ll p = 1 ;
while(a % 2 == 0){
a /= 2 ;
p *= 2 ;
}
v.push_back({a , p});
}
int k;
cin >> k ;
ll sum = 0 , j = 0;
while(k--){
ll a ;
cin >> a ;
a -- ;
while(sum <= a)
sum += v[j++].second ;
cout << v[j - 1].first << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
20 ms |
4988 KB |
Output is correct |
4 |
Correct |
25 ms |
2500 KB |
Output is correct |
5 |
Correct |
42 ms |
5684 KB |
Output is correct |
6 |
Correct |
26 ms |
5068 KB |
Output is correct |
7 |
Correct |
42 ms |
5604 KB |
Output is correct |
8 |
Correct |
43 ms |
5784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
320 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 |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
336 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 |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
20 ms |
4988 KB |
Output is correct |
4 |
Correct |
25 ms |
2500 KB |
Output is correct |
5 |
Correct |
42 ms |
5684 KB |
Output is correct |
6 |
Correct |
26 ms |
5068 KB |
Output is correct |
7 |
Correct |
42 ms |
5604 KB |
Output is correct |
8 |
Correct |
43 ms |
5784 KB |
Output is correct |
9 |
Correct |
0 ms |
328 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
320 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 |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
336 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 |
24 ms |
3284 KB |
Output is correct |
24 |
Correct |
34 ms |
6020 KB |
Output is correct |
25 |
Correct |
56 ms |
8940 KB |
Output is correct |
26 |
Correct |
39 ms |
5744 KB |
Output is correct |
27 |
Correct |
37 ms |
6032 KB |
Output is correct |
28 |
Correct |
71 ms |
9360 KB |
Output is correct |
29 |
Correct |
66 ms |
8900 KB |
Output is correct |
30 |
Correct |
34 ms |
3828 KB |
Output is correct |
31 |
Correct |
73 ms |
9200 KB |
Output is correct |