# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
168144 | crushteacherswife | 쌀 창고 (IOI11_ricehub) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Rochy
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define fl(i,a,b) for(int i=a;i<b;++i)
#define fa(i,a) for(auto (i):(a))
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define vi vector <int>
#define ii pair <int,int>
#define pb push_back
using namespace std;
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));
if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar()))x=x*10+c-48;if(nega)x=-x;}
template <typename T> inline void writep(T x){if(x>9)writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
template <typename R, typename D> inline void Min(R &a, D b){if(a>b) a=b;}
template <typename D, typename R> inline void Max(D &a, R b){if(a<b) a=b;}
const int N=100005,M=300005;
int n,lim,sum[N];
long long cost;
bool check(int x){
int run=(x+1)/2;
int l=1;
int r=x;
long long cur=0;
fl(i,1,run) cur+=sum[run]-sum[i];
fo(i,run+1,x) cur+=sum[i]-sum[run];
for(;r<=n;){
if(cur<=cost) return 1;
cur-=sum[l+1]-sum[l];
cur+=sum[r+1]-sum[r];
++l,++r;
}
return 0;
}
int main(){
ios_base::sync_with_stdio(NULL);
cin. tie(NULL); cout. tie(NULL);
#ifndef ONLINE_JUDGE
// freopen(".inp" , "r", stdin);
#endif
cin>>n>>lim;
fo(i,1,n){
cin>>sum[i];
}
cin>>cost;
int r=n+1;int l=1;
while(r-l>1){
int mid=(l+r)>>1;
if(check(mid)) l=mid;
else r=mid;
}
cout<<l;
return 0;
}