Submission #1116474

#TimeUsernameProblemLanguageResultExecution timeMemory
1116474heeyIntercastellar (JOI22_ho_t1)C++14
100 / 100
143 ms14888 KiB
#include<bits/stdc++.h> using namespace std; #define int long long signed main(){ //ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; i++) cin >> a[i]; int q; cin >> q; vector<int> query(q); for(int i = 0; i < q; i++) cin >> query[i]; vector<pair<int,int>> w; for(int i = 0; i < n; i++){ if(a[i] % 2 != 0) w.emplace_back(a[i], 1); else { int t = 1; while(a[i] % 2 == 0){ a[i] /= 2; t <<= 1; } w.emplace_back(a[i], t); } } vector<int> pr(w.size()); pr[0] = w[0].second; for(int i = 1; i < n; i++) pr[i] = pr[i-1] + w[i].second; for(int i = 0; i < q; i++){ int pos = lower_bound(pr.begin(), pr.end(), query[i]) - pr.begin(); cout << w[pos].first << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...