Submission #1032646

#TimeUsernameProblemLanguageResultExecution timeMemory
1032646juicyIntercastellar (JOI22_ho_t1)C++17
100 / 100
69 ms10180 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #endif int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } function<int(int)> rec = [&](int x) { if (x & 1) { return 1; } return 2 * rec(x / 2); }; vector<pair<int, long long>> B; for (int i = 0; i < N; ++i) { int x = A[i]; while (x % 2 == 0) { x /= 2; } B.push_back({x, rec(A[i])}); } for (int i = 1; i < N; ++i) { B[i].second += B[i - 1].second; } int Q; cin >> Q; while (Q--) { long long X; cin >> X; int L = 0, R = N - 1, res = -1; while (L <= R) { int md = (L + R) / 2; if (B[md].second >= X) { res = md; R = md - 1; } else { L = md + 1; } } cout << B[res].first << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...