Submission #411651

# Submission time Handle Problem Language Result Execution time Memory
411651 2021-05-25T16:45:03 Z A_D Rice Hub (IOI11_ricehub) C++14
17 / 100
19 ms 4044 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define LL long long
const int NN=1e5+100;
LL a[NN];
LL pre[NN];
LL suf[NN];
LL n,b;
bool ok(LL mid)
{
    LL l=1,r=mid,me=0;
    while(r<=n){
        LL avg=(pre[r]-pre[l-1])/mid;
        while(a[me+1]<=avg&&me<n){
            me++;
        }
        LL ret=avg*(me-l+1)-(pre[me]-pre[l-1]);
        ret+=(pre[r]-pre[me])-avg*(r-me);
        if(ret<=b)return 1;
        avg++;
        ret=avg*(me-l+1)-(pre[me]-pre[l-1]);
        ret+=(pre[r]-pre[me])-avg*(r-me);
        if(ret<=b)return 1;
        l++;
        r++;
    }
    return 0;
}
int besthub(int R, int L, int X[], long long B)
{
    n=R;
    b=B;
    for(int i=0;i<R;i++)a[i+1]=X[i];
    for(int i=1;i<=n;i++)pre[i]=pre[i-1]+a[i];
    for(int i=n;i>=1;i--)suf[i]=suf[i+1]+a[i];
    LL l=1,r=n,ans=0;
    while(l<=r){
//        cout<<5<<endl;
        LL mid=(l+r)/2;
        if(ok(mid)){
            l=mid+1;
            ans=mid;
        }
        else r=mid-1;
    }
    int ann=ans;
    return ann;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 292 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 296 KB Output is correct
27 Incorrect 1 ms 332 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 2 ms 304 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 3 ms 460 KB Output is correct
22 Correct 2 ms 460 KB Output is correct
23 Correct 2 ms 460 KB Output is correct
24 Correct 2 ms 460 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Incorrect 2 ms 460 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 936 KB Output is correct
2 Correct 6 ms 952 KB Output is correct
3 Correct 17 ms 3996 KB Output is correct
4 Correct 18 ms 4000 KB Output is correct
5 Correct 12 ms 2024 KB Output is correct
6 Correct 13 ms 1996 KB Output is correct
7 Correct 19 ms 3788 KB Output is correct
8 Correct 17 ms 3908 KB Output is correct
9 Correct 11 ms 1868 KB Output is correct
10 Correct 12 ms 1968 KB Output is correct
11 Correct 17 ms 4044 KB Output is correct
12 Correct 17 ms 4032 KB Output is correct
13 Incorrect 17 ms 1996 KB Output isn't correct
14 Halted 0 ms 0 KB -