# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1221626 | mingga | Intercastellar (JOI22_ho_t1) | C++20 | 41 ms | 5444 KiB |
#include "bits/stdc++.h"
using namespace std;
#define ln "\n"
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define int long long
const int mod = 1e9 + 7;
const int inf = 2e18;
const int N = 2e5 + 7;
int n, q;
pair<int, int> d[N];
signed main() {
cin.tie(0) -> sync_with_stdio(0);
#define task ""
if(fopen(task ".INP", "r")) {
freopen(task ".INP", "r", stdin);
freopen(task ".OUT", "w", stdout);
}
cin >> n;
for(int i = 1; i <= n; i++) {
int x; cin >> x;
int cnt = 0;
for(int j = 0; (1 << j) <= x; j++) {
if(x >> j & 1) break;
cnt++;
}
d[i] = {(1 << (cnt)), (x >> cnt)};
// cerr << i << ' ' << d[i].fi << ' ' << d[i].se << ln;
}
cin >> q;
int cur = 0;
int id = 0;
for(int i = 1; i <= q; i++) {
int x; cin >> x;
x -= cur;
while(id < n and x > d[id].fi) x -= d[id].fi, cur += d[id++].fi;
cout << d[id].se << ln;
}
cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |