Submission #648846

#TimeUsernameProblemLanguageResultExecution timeMemory
648846GoodkNightIntercastellar (JOI22_ho_t1)C++17
100 / 100
453 ms9148 KiB
#include<iostream> using namespace std; long long ciasta[200008][2]; int binsearch(long long x, int n){ int p=0; int k = n-1; while(p!=k){ int mid=(p+k)/2; if(ciasta[mid][0]==x){ return (mid); } else{ if(ciasta[mid][0]>x){ k = mid; } else{ p=mid+1; } } } return(k); } void dwoj(int a, int i){ unsigned int odp=1; while(a%2==0){ odp=odp*2; a=a/2; } ciasta[i][0]=odp; ciasta[i][1]=a; } int main(){ long long n, q, a; cin >> n; for(int i=0; i<n; i++){ cin >> a; dwoj(a, i); } for(int i=1; i<n; i++){ ciasta[i][0]+=ciasta[i-1][0]; } cin >> q; long long x; for(int i=0; i<q; i++){ cin >> x; cout << ciasta[binsearch(x, n)][1]<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...