#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
using ll = long long;
using ld = long double;
const string FILENAME = "input";
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
//read(FILENAME);
int n;
cin >> n;
vector<pair<ll, ll>> v;
for (int i = 1; i <= n; i++) {
ll x;
cin >> x;
ll cnt = 1;
while (x % 2 == 0) {
x /= 2;
cnt *= 2;
}
v.pb(mp(cnt, x));
}
vector<ll> pref(n + 1, 0);
for (int i = 1; i <= sz(v); i++) {
pref[i] = pref[i - 1] + v[i - 1].first;
}
int q;
cin >> q;
while (q--) {
ll x;
cin >> x;
ll pos = lower_bound(all(pref), x) - pref.begin();
cout << v[pos - 1].second << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
18 ms |
6212 KB |
Output is correct |
4 |
Correct |
23 ms |
2768 KB |
Output is correct |
5 |
Correct |
41 ms |
8116 KB |
Output is correct |
6 |
Correct |
24 ms |
5844 KB |
Output is correct |
7 |
Correct |
41 ms |
7104 KB |
Output is correct |
8 |
Correct |
41 ms |
7604 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 |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
456 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 |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 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 |
18 ms |
6212 KB |
Output is correct |
4 |
Correct |
23 ms |
2768 KB |
Output is correct |
5 |
Correct |
41 ms |
8116 KB |
Output is correct |
6 |
Correct |
24 ms |
5844 KB |
Output is correct |
7 |
Correct |
41 ms |
7104 KB |
Output is correct |
8 |
Correct |
41 ms |
7604 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 |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
456 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 |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
21 ms |
3292 KB |
Output is correct |
24 |
Correct |
29 ms |
7492 KB |
Output is correct |
25 |
Correct |
53 ms |
10436 KB |
Output is correct |
26 |
Correct |
36 ms |
6600 KB |
Output is correct |
27 |
Correct |
34 ms |
8128 KB |
Output is correct |
28 |
Correct |
73 ms |
10916 KB |
Output is correct |
29 |
Correct |
65 ms |
10900 KB |
Output is correct |
30 |
Correct |
29 ms |
4080 KB |
Output is correct |
31 |
Correct |
60 ms |
11660 KB |
Output is correct |