# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
536443 | fdnfksd | 쌀 창고 (IOI11_ricehub) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define TASKNAME "codeforce"
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pair1 vector<pair<int,int>>
#define pop1 pop_back
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxN=2e5;
const ll maxM=1e5;
const ll INF=-1e10;
const ll mod=123456789;
ll r[maxM],T[maxN]={0},res=0,K,L,n;
bool check(ll s, ll t)
{
ll p=(s+t)/2;
return (p - s)*r[p] - (T[p] - T[s]) + (T[t + 1] - T[p + 1]) - (t - p)*r[p]<=K;
}
void Input()
{
cin >> n >> L >> K;
for(int i=0;i<n;i++) cin >> r[i];
T[0]=0;
for(int i=1;i<=n;i++) T[i]=T[i-1]+r[i-1];
for(int i=0;i<n;i++)
{
ll l=i,r=n-1;
while(l<=r)
{
ll mid=(l+r)/2;
if(check(i,mid)) l=mid+1;
else r=mid-1;
}
res=max(res,r-i+1);
}
cout << res <<'\n';
}
void Init()
{
}
void Solve()
{
}
void Print()
{
}
int main()
{
fastio
//freopen(TASKNAME".INP","r",stdin);
//freopen(TASKNAME".OUT","w",stdout);
Input();
Init();
Solve();
Print();
}