Submission #886546

#TimeUsernameProblemLanguageResultExecution timeMemory
886546dubabubaIntercastellar (JOI22_ho_t1)C++14
100 / 100
403 ms10760 KiB
#include <iostream> using namespace std; #define int long long typedef pair<int, int> pii; #define ff first #define ss second #define MP make_pair const int mxl = 30; const int mxn = 2e5 + 10; int a[mxn], n, q; pii p[mxn]; void build() { for(int i = 1; i <= n; i++) { const int &A = a[i]; for(int k = 0; k < mxl; k++) if(A & (1LL << k)) { p[i].ff = (1LL << k); p[i].ss = (A >> k); break; } p[i].ff += p[i - 1].ff; } } int solve(int x) { auto it = lower_bound(p + 1, p + n + 1, MP(x, 0LL)); return (*it).ss; } signed main() { cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; build(); cin >> q; while(q--) { int x; cin >> x; cout << solve(x) << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...