Submission #219818

# Submission time Handle Problem Language Result Execution time Memory
219818 2020-04-06T12:42:47 Z LittleFlowers__ Rice Hub (IOI11_ricehub) C++14
17 / 100
9 ms 512 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

//long long s[100010];

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[100010];
main(){
    #define task "rice"
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);

    int r,l; long long 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
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 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 Correct 4 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 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 -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -