Submission #938601

#TimeUsernameProblemLanguageResultExecution timeMemory
938601vjudge1Intercastellar (JOI22_ho_t1)C++17
100 / 100
379 ms5492 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int n, q, temp; vector<int> a, prefix; signed main() { cin >> n; a = vector<int>(n), prefix = vector<int>(n); for(int i = 0; i < n; i++) { cin >> a[i]; temp = __builtin_ctz(a[i]); a[i] /= (1 << temp); prefix[i] = (1 << temp); if(i > 0) prefix[i] += prefix[i - 1]; } cin >> q; while(q--) { cin >> temp; int l = 0, r = n, mid, ans = 0; while(l<=r) { mid = (l + r) / 2; if(prefix[mid] < temp) { ans = mid + 1; l = mid + 1; } else r = mid - 1; } cout << a[ans] << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...