Submission #1023958

#TimeUsernameProblemLanguageResultExecution timeMemory
1023958AcanikolicIntercastellar (JOI22_ho_t1)C++14
100 / 100
63 ms10832 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define F first #define S second using namespace std; const int N = 2e5 + 10; const int mod = 1e9 + 7; const int inf = 1e9; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<int>a(n + 1); vector<pair<int,int>>pref(n + 1); for(int i = 1; i <= n; i++) { cin >> a[i]; int pw = 1; while(a[i] % (pw * 2) == 0) pw *= 2; pref[i] = {a[i] / pw,pw}; pref[i].S += pref[i - 1].S; } int q; cin >> q; while(q--) { int x; cin >> x; int l = 1,r = n,ans = 0; while(l <= r) { int mid = (l + r) / 2; if(pref[mid].S <= x) { ans = mid; l = mid + 1; }else { r = mid - 1; } } if(pref[ans].S < x) ans++; cout << pref[ans].F << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...