Submission #308205

# Submission time Handle Problem Language Result Execution time Memory
308205 2020-09-30T09:46:23 Z juggernaut Rice Hub (IOI11_ricehub) C++14
100 / 100
19 ms 3072 KB
#include"ricehub.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[100005];
ll b,pref[100005],suff[100005];
ll pref_calc(ll l,ll r){
    return pref[r]-1ll*(l-1)*(a[r]-a[l-1])-pref[l-1];
}
ll suff_calc(ll l,ll r){
    return suff[l]-1ll*(n-r)*(a[r+1]-a[l])-suff[r+1];
}
bool app(ll l,ll r){
    ll i=(l+r)>>1ll;
    ll mn=pref_calc(l,i)+suff_calc(i,r);
    return mn<=b;
}
int besthub(int N,int L,int A[],ll B){
    n=N;b=B;
    for(int i=0;i<n;i++)a[i+1]=A[i];
    for(int i=1;i<=n;i++)
        pref[i]=pref[i-1]+(i-1)*(a[i]-a[i-1]);
    for(int i=n;i>=1;i--)
        suff[i]=suff[i+1]+(n-i)*(a[i+1]-a[i]);
    int l=1,r=1,mx=1;
    while(r<n){
        r++;
        while(!app(l,r))l++;
        mx=max(mx,r-l+1);
    }
    return mx;
}
//#include"grader.cpp"
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 0 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 512 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 2 ms 512 KB Output is correct
26 Correct 1 ms 416 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 896 KB Output is correct
2 Correct 4 ms 896 KB Output is correct
3 Correct 19 ms 3072 KB Output is correct
4 Correct 19 ms 3072 KB Output is correct
5 Correct 9 ms 1664 KB Output is correct
6 Correct 8 ms 1664 KB Output is correct
7 Correct 15 ms 3072 KB Output is correct
8 Correct 15 ms 3072 KB Output is correct
9 Correct 7 ms 1664 KB Output is correct
10 Correct 7 ms 1664 KB Output is correct
11 Correct 19 ms 3072 KB Output is correct
12 Correct 19 ms 3064 KB Output is correct
13 Correct 9 ms 1664 KB Output is correct
14 Correct 9 ms 1664 KB Output is correct
15 Correct 14 ms 2432 KB Output is correct
16 Correct 14 ms 2304 KB Output is correct
17 Correct 17 ms 2816 KB Output is correct
18 Correct 17 ms 2816 KB Output is correct
19 Correct 19 ms 2944 KB Output is correct
20 Correct 18 ms 2944 KB Output is correct