Submission #994216

#TimeUsernameProblemLanguageResultExecution timeMemory
994216faqinyeagerIntercastellar (JOI22_ho_t1)C++17
0 / 100
76 ms4088 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; vector<ll> a, pw; int main(){ int n; cin >> n; a.resize(n), pw.resize(n, 1); for(int i = 0; i < n; i++){ cin >> a[i]; while(a[i] % 2 == 0){ a[i] /= 2; pw[i] *= 2; } } for(int i = 1; i < n; i++) pw[i] += pw[i - 1]; // for(int i = 0; i < n; i++) cout << a[i] << ' '; cout << '\n'; // for(int i = 0; i < n; i++) cout << pw[i] << ' '; cout << "\n\n"; int Q; cin >> Q; while(Q--){ ll c; cin >> c; int l = 0, r = n - 1; while(r - l > 1){ int m = (l + r) / 2; if(pw[m] <= c){ l = m; // pw[l] <= pw[m] <= c <= pw[r] }else{ r = m - 1; // pw[l] < c < pw[m] <= pw[r] } } cout << ((c > pw[l]) ? a[l + 1] : a[l]) << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...