Submission #1053802

#TimeUsernameProblemLanguageResultExecution timeMemory
1053802dpsaveslivesIntercastellar (JOI22_ho_t1)C++17
100 / 100
53 ms14528 KiB
#include <bits/stdc++.h> #define f first #define s second #define ll long long using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N; cin >> N; vector<pair<ll,ll>> vec; for(int i = 0;i<N;++i){ ll x; cin >> x; ll cur = 1; while(x % cur == 0){ cur *= 2; } cur /= 2; x /= cur; vec.push_back({cur,x}); } int Q; cin >> Q; vector<pair<ll,int>> queries; //value, index for(int i = 0;i<Q;++i){ ll x; cin >> x; queries.push_back({x,i}); } sort(queries.begin(),queries.end()); vector<int> ans(Q,0); int j = 0; ll cnt = 0ll; for(int i = 0;i<Q;++i){ while(j < N && cnt+vec[j].f < queries[i].f){ cnt += vec[j].f; ++j; } ans[queries[i].s] = vec[j].s; } for(int i = 0;i<Q;++i){ cout << ans[i] << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...