Submission #988737

#TimeUsernameProblemLanguageResultExecution timeMemory
988737IrateIntercastellar (JOI22_ho_t1)C++17
100 / 100
67 ms8656 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int>v = {0}; vector<long long>pref(n + 1); for(int i = 1;i <= n;++i){ int a; cin >> a; int cpy = a, cnt = 1; while(cpy % 2 == 0){ cpy /= 2; } cnt = a / cpy; v.push_back(cpy); pref[i] = pref[i - 1] + cnt; } int q; cin >> q; while(q--){ long long x; cin >> x; int l = 1, r = n, ans = -1; while(l <= r){ int mid = (l + r) >> 1; if(pref[mid] >= x){ ans = mid; r = mid - 1; } else{ l = mid + 1; } } cout << v[ans] << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...