Submission #1007744

#TimeUsernameProblemLanguageResultExecution timeMemory
1007744AtinaRIntercastellar (JOI22_ho_t1)C++14
100 / 100
334 ms11264 KiB
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin>>n; long long niza[n]; for(long long i=0; i<n; i++)cin>>niza[i]; long long idx=0; vector<pair<long long,long long> > v; for(long long i=n-1; i>=0; i--) { if(niza[i]%2) { v.push_back({1,niza[i]}); idx++; } else { long long sob=1; while(true) { niza[i]/=2; sob*=2; if(niza[i]%2)break; } v.push_back({sob,niza[i]}); idx+=sob; } } reverse(v.begin(),v.end()); long long q; cin>>q; idx=0; long long sum=0; for(long long i=0; i<q; i++) { long long x; cin>>x; while(true) { if(sum+v[idx].first<x) { sum+=v[idx].first; idx++; } else { cout<<v[idx].second<<endl; break; } } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...