Submission #676551

#TimeUsernameProblemLanguageResultExecution timeMemory
676551ensonlungIntercastellar (JOI22_ho_t1)C++17
100 / 100
89 ms10700 KiB
#include <bits/stdc++.h> using namespace std; int n,m; struct cake{ int len; long long l,r; }a[200005]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; a[0].r=0; for (int i=1;i<=n;i++){ cin>>a[i].len; long long cnt=1; while (a[i].len%2==0){ a[i].len/=2; cnt*=2; } a[i].l=a[i-1].r+1; a[i].r=a[i-1].r+cnt; } cin>>m; while (m--){ long long t,ptl=1,ptr=n,mid; cin>>t; while (ptl<=ptr){ mid=(ptl+ptr)/2; if (a[mid].l<=t && a[mid].r>=t){ cout<<a[mid].len<<"\n"; break; } else if (a[mid].l>t) ptr=mid-1; else ptl=mid+1; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...