Submission #1311510

#TimeUsernameProblemLanguageResultExecution timeMemory
1311510madamadam3Intercastellar (JOI22_ho_t1)C++20
100 / 100
51 ms4560 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int signed main() { cin.tie(0)->sync_with_stdio(0); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<int> pow2(61, 1); for (int i = 1; i < 61; i++) pow2[i] = pow2[i-1] * 2; auto rem = [](int x) { while (x%2 == 0) x/=2; return x; }; auto steps = [](int x) { int r = 0; while (x%2 == 0) { r++; x /= 2; } return r; }; int q; cin >> q; int px = 0, pos = 0, to = pow2[steps(a[0])]; while (q--) { int x; cin >> x; x--; int dx = x-px; px = x; while (dx > 0) { int s = min(to, dx); to -= s; dx -= s; if (to <= 0) { pos++; to = pow2[steps(a[pos])]; } } cout << rem(a[pos]) << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...