#include <iostream>
#include <iomanip>
#include <cassert>
#include <vector>
#include <numeric>
#include <string>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <ctime>
#include <chrono>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)((x).size())
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
//typedef __int128_t int128;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const char en = '\n';
const int INF = 1e9 + 7;
const ll INFLL = 1e18;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
void solve() {
int n;
cin >> n;
vector<pair<int, ll>> a;
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
int p = 0;
while (x % 2 == 0) {
++p;
x /= 2;
}
if (a.empty() || a.back().first != x) {
a.emplace_back(x, 0);
}
if (x == a.back().first) {
a.back().second += (1LL << p);
}
}
int q;
cin >> q;
int ptr = -1;
ll sum = 0;
while (q--) {
ll i;
cin >> i;
while (i > sum) {
++ptr;
sum += a[ptr].second;
}
cout << a[ptr].first << en;
}
}
int main() {
#ifdef __APPLE__
freopen("input.txt", "r", stdin);
#else
ios_base::sync_with_stdio(0);
cin.tie(0);
#endif
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
20 ms |
3128 KB |
Output is correct |
4 |
Correct |
30 ms |
2252 KB |
Output is correct |
5 |
Correct |
48 ms |
5156 KB |
Output is correct |
6 |
Correct |
28 ms |
2896 KB |
Output is correct |
7 |
Correct |
49 ms |
4076 KB |
Output is correct |
8 |
Correct |
40 ms |
2528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
328 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 |
1 ms |
340 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 |
328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
20 ms |
3128 KB |
Output is correct |
4 |
Correct |
30 ms |
2252 KB |
Output is correct |
5 |
Correct |
48 ms |
5156 KB |
Output is correct |
6 |
Correct |
28 ms |
2896 KB |
Output is correct |
7 |
Correct |
49 ms |
4076 KB |
Output is correct |
8 |
Correct |
40 ms |
2528 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 |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
328 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 |
1 ms |
340 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 |
328 KB |
Output is correct |
23 |
Correct |
27 ms |
3108 KB |
Output is correct |
24 |
Correct |
36 ms |
5984 KB |
Output is correct |
25 |
Correct |
81 ms |
8888 KB |
Output is correct |
26 |
Correct |
44 ms |
5664 KB |
Output is correct |
27 |
Correct |
41 ms |
6092 KB |
Output is correct |
28 |
Correct |
81 ms |
9248 KB |
Output is correct |
29 |
Correct |
67 ms |
5532 KB |
Output is correct |
30 |
Correct |
42 ms |
3712 KB |
Output is correct |
31 |
Correct |
85 ms |
8776 KB |
Output is correct |