Submission #543190

# Submission time Handle Problem Language Result Execution time Memory
543190 2022-03-29T18:07:46 Z ogibogi2004 Rice Hub (IOI11_ricehub) C++14
100 / 100
15 ms 2516 KB


#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll MAXN=1e5+6;
ll cc,le,re;
ll x[MAXN];
void add()
{
    re++;
    cc+=x[re]-x[le+(re-le)/2];
    /*if((re-le)%2==0&&!(re==0&&le==0))
    {
        cc-=x[le+(re-le)/2]-x[le+(re-le)/2-1];
    }*/
}
void rmv()
{
    cc-=x[le+(re-le)/2]-x[le];
    le++;
    if((re-le)%2==0)
    {
        cc-=x[le+(re-le)/2]-x[le+(re-le)/2-1];
    }
}
int besthub(int R, int L, int X[], long long B)
{
    for(int i=0;i<R;i++)x[i]=X[i];
    cc=0;
    le=0,re=-1;
    ll ans=0;
    for(le=0;le<R;)
    {
        while(re+1<R&&cc<=B)
        {
            add();
            //cout<<le<<" "<<re<<" "<<cc<<endl;
        }
        if(cc<=B)ans=max(ans,re-le+1);
        else ans=max(ans,re-le);
        rmv();
        //cout<<le<<" "<<re<<" "<<cc<<endl;
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 352 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 324 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 1 ms 324 KB Output is correct
28 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 596 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 14 ms 2436 KB Output is correct
4 Correct 12 ms 2516 KB Output is correct
5 Correct 5 ms 1236 KB Output is correct
6 Correct 6 ms 1208 KB Output is correct
7 Correct 11 ms 2260 KB Output is correct
8 Correct 12 ms 2136 KB Output is correct
9 Correct 6 ms 1076 KB Output is correct
10 Correct 6 ms 1116 KB Output is correct
11 Correct 15 ms 2428 KB Output is correct
12 Correct 13 ms 2516 KB Output is correct
13 Correct 6 ms 1260 KB Output is correct
14 Correct 6 ms 1200 KB Output is correct
15 Correct 9 ms 2004 KB Output is correct
16 Correct 9 ms 1972 KB Output is correct
17 Correct 11 ms 2216 KB Output is correct
18 Correct 11 ms 2248 KB Output is correct
19 Correct 11 ms 2388 KB Output is correct
20 Correct 13 ms 2388 KB Output is correct