Submission #594514

#TimeUsernameProblemLanguageResultExecution timeMemory
5945141neIntercastellar (JOI22_ho_t1)C++14
100 / 100
96 ms10756 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n;cin>>n; vector<pair<long long,long long>>arr; for (int i = 0;i<n;++i){ long long x;cin>>x; int counts = 1; while(x % 2 == 0){ x/=2; counts*=2; } if (!arr.empty()){ if (arr.back().first == x){ arr.back().second+=counts; } else{ arr.push_back({x,counts}); } } else{ arr.push_back({x,counts}); } } int m = (int)arr.size(); vector<long long>pref(m + 1,0); for (int i = 0;i<m;++i){ pref[i + 1] = pref[i] + arr[i].second; } int q;cin>>q; for (int i = 0;i<q;++i){ long long x;cin>>x; int temp = lower_bound(pref.begin(),pref.end(),x) - pref.begin(); cout<<arr[temp - 1].first<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...