#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
#define PB push_back
#define PF push_front
#define PPB pop_back
#define PPF pop_front
#define X first
#define Y second
#define MP make_pair
#define all(x) (x).begin(), (x).end()
const int mod = 1e9 + 7; //998244353;
const int inf = 1e9 + 7;
const ll INF = 1e18 + 7;
const int logo = 20;
const int MAXN = 1e6 + 7;
const int off = 1 << logo;
const int trsz = off << 1;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
vpll niz;
void solve(){
int n;
cin >> n;
ll cs = 0;
for(int i=0; i<n; i++){
ll x, y;
cin >> x;
y = x;
while(y % 2 == 0) y /= 2;
cs += x / y;
niz.PB({y, cs});
}
int q;
cin >> q;
int cans = 0;
while(q--){
ll x;
cin >> x;
while(niz[cans].Y < x) cans++;
cout << niz[cans].X << "\n";
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int tt = 1;
//cin >> tt;
while(tt--) solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
17 ms |
5304 KB |
Output is correct |
4 |
Correct |
22 ms |
2640 KB |
Output is correct |
5 |
Correct |
37 ms |
6868 KB |
Output is correct |
6 |
Correct |
23 ms |
5076 KB |
Output is correct |
7 |
Correct |
40 ms |
6352 KB |
Output is correct |
8 |
Correct |
37 ms |
5840 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 |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 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 |
1 ms |
500 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
17 ms |
5304 KB |
Output is correct |
4 |
Correct |
22 ms |
2640 KB |
Output is correct |
5 |
Correct |
37 ms |
6868 KB |
Output is correct |
6 |
Correct |
23 ms |
5076 KB |
Output is correct |
7 |
Correct |
40 ms |
6352 KB |
Output is correct |
8 |
Correct |
37 ms |
5840 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 |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 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 |
1 ms |
500 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
21 ms |
3280 KB |
Output is correct |
24 |
Correct |
27 ms |
6100 KB |
Output is correct |
25 |
Correct |
49 ms |
9924 KB |
Output is correct |
26 |
Correct |
36 ms |
6088 KB |
Output is correct |
27 |
Correct |
32 ms |
7124 KB |
Output is correct |
28 |
Correct |
59 ms |
9304 KB |
Output is correct |
29 |
Correct |
57 ms |
8892 KB |
Output is correct |
30 |
Correct |
29 ms |
3792 KB |
Output is correct |
31 |
Correct |
65 ms |
9200 KB |
Output is correct |