제출 #1295141

#제출 시각아이디문제언어결과실행 시간메모리
1295141ghammazhassan쌀 창고 (IOI11_ricehub)C++20
42 / 100
2 ms580 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<int>pr(n); for (int i=1;i<n;i++){ pr[i]=pr[i-1]+a[i]-a[0]; } vector<int>sf(n); for (int i=n-2;i>=0;i--){ sf[i]=sf[i+1]+a[n-1]-a[i]; } int ans=1; for (int i=0;i<n;i++){ int l=i; int h=n-1; int mi=(l+h+1)/2; while (l<h){ int 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...