제출 #129332

#제출 시각아이디문제언어결과실행 시간메모리
129332arnold518쌀 창고 (IOI11_ricehub)C++14
100 / 100
48 ms1292 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;

int N, L, X[MAXN+10], ans=1;
ll B;

int besthub(int RR, int LL, int XX[], ll BB)
{
    int i, j;
    N=RR; L=LL; B=BB;
    for(i=0; i<N; i++) X[i]=XX[i];

    ll cost=0;
    int lp=0, rp=0;
    for(; lp<N; lp++)
    {
        //printf("%d %d %lld\n", lp, rp, cost);
        for(; rp<N && cost<=B; rp++)
        {
            //printf("%d %d %lld\n", lp, rp, cost);
            ans=max(ans, rp-lp+1);
            int mid=(lp+rp+1)>>1;
            cost+=X[rp+1]-X[mid];
        }
        //printf("%d %d %lld\n", lp, rp, cost);
        int mid=(lp+rp+1)>>1;
        cost-=X[mid]-X[lp];
    }
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

ricehub.cpp: In function 'int besthub(int, int, int*, ll)':
ricehub.cpp:15:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...