Submission #651494

# Submission time Handle Problem Language Result Execution time Memory
651494 2022-10-19T05:16:29 Z andrei_boaca Rice Hub (IOI11_ricehub) C++14
100 / 100
18 ms 3328 KB
#include <bits/stdc++.h>
#include "ricehub.h"
//#include "grader.cpp"
typedef long long ll;
ll n,m,maxi,v[200005],s[200005];
bool check(int i,int j,int poz)
{
    if(poz<i||poz>j)
        return 0;
    ll inlft=(poz-i+1);
    ll slft=s[poz]-s[i-1];
    ll suma=0;
    suma+=inlft*v[poz]-slft;

    ll inrgt=(j-poz+1);
    ll srgt=s[j]-s[poz-1];
    suma+=srgt-inrgt*v[poz];
    return suma<=maxi;
}
bool ok(int lg)
{
    for(int i=1;i<=n;i++)
    {
        int j=i+lg-1;
        if(j>n)
            break;
        int mij=(i+j)/2;
        for(int poz=mij-1;poz<=mij+1;poz++)
            if(check(i,j,poz))
                return 1;
    }
    return 0;
}
int besthub(int R, int L, int X[], long long B)
{
    n=R;
    m=L;
    maxi=B;
    for(int i=0;i<n;i++)
        v[i+1]=X[i];
    for(int i=1;i<=n;i++)
        s[i]=s[i-1]+v[i];
    int ans=0;
    int st=1;
    int dr=n;
    while(st<=dr)
    {
        int mij=(st+dr)/2;
        if(ok(mij))
        {
            ans=mij;
            st=mij+1;
        }
        else
            dr=mij-1;
    }
    return ans;
}
# 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 304 KB Output is correct
4 Correct 1 ms 308 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 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 224 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 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 212 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 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 312 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 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 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 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 452 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 852 KB Output is correct
2 Correct 6 ms 788 KB Output is correct
3 Correct 18 ms 3328 KB Output is correct
4 Correct 13 ms 3268 KB Output is correct
5 Correct 11 ms 1620 KB Output is correct
6 Correct 11 ms 1588 KB Output is correct
7 Correct 14 ms 3048 KB Output is correct
8 Correct 10 ms 3028 KB Output is correct
9 Correct 10 ms 1576 KB Output is correct
10 Correct 10 ms 1584 KB Output is correct
11 Correct 12 ms 3276 KB Output is correct
12 Correct 13 ms 3276 KB Output is correct
13 Correct 11 ms 1620 KB Output is correct
14 Correct 11 ms 1656 KB Output is correct
15 Correct 9 ms 2488 KB Output is correct
16 Correct 9 ms 2480 KB Output is correct
17 Correct 11 ms 2900 KB Output is correct
18 Correct 12 ms 2964 KB Output is correct
19 Correct 15 ms 3124 KB Output is correct
20 Correct 12 ms 3132 KB Output is correct