Submission #789410

#TimeUsernameProblemLanguageResultExecution timeMemory
789410AndreyIntercastellar (JOI22_ho_t1)C++14
100 / 100
65 ms9384 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n,q,a,l,r,m; cin >> n; vector<long long> pr(1); vector<long long> haha(0); for(long long i = 0; i < n; i++) { cin >> a; pr.push_back(1); while(a%2 == 0) { a/=2; pr[i+1]*=2; } haha.push_back(a); } for(long long i = 1; i <= n; i++) { pr[i]+=pr[i-1]; } cin >> q; for(long long i = 0; i < q; i++) { cin >> a; l = 0; r = n; while(l < r) { m = (l+r)/2; if(pr[m] >= a) { r = m; } else { l = m+1; } } cout << haha[l-1] << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...