답안 #219812

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
219812 2020-04-06T12:39:24 Z LittleFlowers__ 쌀 창고 (IOI11_ricehub) C++14
17 / 100
9 ms 640 KB
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);

//#define unx 1

#ifndef unx
#include "ricehub.h"
#endif // unx

int besthub(int r,int l,int x[],long long b){
    int best=0;
    vector<long long> s(r+1);
    forinc(i,1,r) s[i]=s[i-1]+x[i-1];
    int le,mi,ri,ret;
    forinc(i,1,r){
        le=0,ri=min(i-1,r-i),ret=-1;
        while(le<=ri){
            mi=(le+ri)/2;
            if(s[i+mi]-s[i]-s[i-1]+s[i-mi-1]<=b) ret=mi,le=mi+1;
            else ri=mi-1;
        }
        best=max(best,ret+ret+1);
        le=0,ri=min(i-1,r-i),ret=-1;
        while(le<=ri){
            mi=(le+ri)/2;
            if(s[i+mi+1]-s[i]-s[i-1]+s[i-mi-1]-x[i-1]<=b) ret=mi,le=mi+1;
            else ri=mi-1;
        }
        best=max(best,ret+ret+2);
    }
    return best;
}
#ifdef unx

int a[1010];
main(){
    #define task "rice"
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);

    int r,l,b;
    cin>>r>>l>>b;
    forinc(i,1,r) cin>>a[i-1];
    cout<<besthub(r,l,a,b);
    cerr<<besthub(r,l,a,b);

}
#endif // unx
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Incorrect 5 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -