제출 #1295233

#제출 시각아이디문제언어결과실행 시간메모리
1295233ghammazhassan쌀 창고 (IOI11_ricehub)C++20
100 / 100
13 ms3232 KiB
#include "ricehub.h" #include <iostream> #include <cmath> #include <algorithm> #include <map> #include <unordered_map> #include <vector> #include <iomanip> #include <string> #include <queue> #include <set> #include <deque> #define MAX_R 1000000 using namespace std; #define ll long long int n; ll m,x; int besthub(int R,int L,int X[],ll B){ n=R,m=L,x=B; vector<ll>a(n); for (int i=0;i<n;i++){ a[i]=X[i]; } vector<ll>pr(n); for (int i=1;i<n;i++){ pr[i]=pr[i-1]+a[i]-a[0]; } vector<ll>sf(n); for (int i=n-2;i>=0;i--){ sf[i]=sf[i+1]+a[n-1]-a[i]; } ll ans=1; for (ll i=0;i<n;i++){ ll l=i; ll h=n-1; ll mi=(l+h+1)/2; while (l<h){ ll u=(i+mi)/2; if (pr[mi]-pr[u]-(mi-u)*(a[u]-a[0])+sf[i]-sf[u]-(u-i)*(a[n-1]-a[u])<=x){ l=mi; } else{ h=mi-1; } mi=(l+h+1)/2; } ans=max(ans,l-i+1); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...