Submission #910521

#TimeUsernameProblemLanguageResultExecution timeMemory
910521SuPythonyIntercastellar (JOI22_ho_t1)C++17
100 / 100
374 ms10156 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin>>n; vector<ll> p(n); vector<int> eind; ll m=0; for (int i=0; i<n; i++) { cin>>p[i]; m=max(m,p[i]); if (p[i]%2==0) { eind.push_back(i); } } vector<ll> c(n); // pf of no of nos p[i] divides into for (int i=0; i<n; i++) { if (i==0) { c[i]=p[i]&-p[i]; } else { c[i]=c[i-1]+(p[i]&-p[i]); } } int q; cin>>q; while (q--) { ll x; cin>>x; auto it=lower_bound(c.begin(),c.end(),x); int ind=it-c.begin(); ll n;//no of elements in that if (ind==0) n=*it; else n=*it-c[ind-1]; if (n==1) cout<<p[ind]<<"\n"; else if (n==p[ind]) cout<<1<<"\n"; else cout<<p[ind]/n<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...