| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 693305 | Ahmed57 | 쌀 창고 (IOI11_ricehub) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
//#include "ricehub.h"
using namespace std;
int besthub(int R,int L,vector<int> X,long long B){
long long r =0 ;
long long pref[R];
pref[0] = X[0];
for(int i = 1;i<R;i++){
pref[i] = X[i]+pref[i-1];
}
long long ans = 0;
for(int l= 0;l<R;l++){
while(r<R){
int mid=(l+r)/2;
long long e1 = pref[mid];
if(l!=0)e1-=pref[l-1];
e1 = (X[mid]*(mid-l+1))-e1;
long long e2 = pref[r]-pref[mid];
e2 = e2-(X[mid]*(r-mid));
if(e1+e2<=B){
r++;
}else break;
}
ans = max(ans,r-l);
}
return ans;
}
/*int main(){
vector<int>v = {1,2,10,12,14};
cout<<besthub(5,20,v,6);
}*/
