제출 #73762

#제출 시각아이디문제언어결과실행 시간메모리
73762renatsj커다란 상품 (IOI17_prize)C++14
20 / 100
4 ms576 KiB
#include<bits/stdc++.h> #include "prize.h" using namespace std; int i,j,n,m,ll,rr,xl,xr,last,rez,mas[200005][2]; vector<int> aa; int bins(int sum,int l,int r) { ll=0; rr=n-1; int c=l+(r-l)/2; while (l<r) { int c2=0; aa=ask(c); xl=aa[0]; xr=aa[1]; mas[c][0]=xl; mas[c][1]=xr; if (xl+xr<=sum) { return c; } if (xl>0) { r=c-1; c2=bins(xl+xr,l,r); if (mas[c2][0]+mas[c2][1]<=sum) { return c2; } if (mas[c2][0]+mas[c2][1]<mas[c][0]+mas[c][1]) { l=0; r=n-1; c=c2; } else if (mas[c2][0]!=mas[c][0]) { l=c2+1; c=l+(r-l)/2; } else { r=c2-1; c=l+(r-l)/2; } } else { l=c+1; c2=bins(xl+xr,l,r); if (mas[c2][0]+mas[c2][1]<=sum) { return c2; } if (mas[c2][0]+mas[c2][1]<mas[c][0]+mas[c][1]) { l=0; r=n-1; c=c2; } else if (mas[c2][1]!=mas[c][1]) { r=c2-1; c=l+(r-l)/2; } else { l=c2+1; c=l+(r-l)/2; } } } return l; } int find_best(int n) { return bins(0,0,n-1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...