Submission #552021

# Submission time Handle Problem Language Result Execution time Memory
552021 2022-04-22T08:18:31 Z ala2 Rice Hub (IOI11_ricehub) C++14
100 / 100
14 ms 3284 KB
 //   #include "ricehub.h"
    #include <iostream>
    using namespace std;
    long long n,d;
    long long a[1000100];
    long long b;
    long long P[1001000];
    long long f(long long i,long long j)
    {
        long long x=(i+j)/2;
        long long ta=j-i+1;
        long long one=P[x]-P[i]+a[i]-a[x];
        long long g=0;
        long long ta1=x-i;
        g=ta1*a[x]-one;
        long long tow=P[j]-P[x];
        long long ta2=j-x;
        g+=tow-ta2*a[x];
        return g;
    }
    long long ok(long long mid)
    {
        for(long long i=0;i<n;i++)
        {
            if(i+mid>=n)
                break;
            if(f(i,i+mid)<=b)
            {
                return 1;
            }
        }
        return 0;
    }
    int besthub(int R, int L, int X[], long long B)
    {
        n=R;
        d=L;
        b=B;
        for(long long i=0;i<n;i++)
            a[i]=X[i];
        P[0]=a[0];
        for(long long i=1;i<n;i++)
          P[i]=P[i-1]+a[i];
        long long mx=1;
        long long l=0;
        long long r=n;
        while(r-l>1)
        {
            long long mid=(l+r)/2;
            if(ok(mid))
            {
                l=mid;
            }
            else r=mid;
        }

        long long ann=l+1;
        //cout<<mx<<endl;
        return ann;
    }

Compilation message

ricehub.cpp: In function 'long long int f(long long int, long long int)':
ricehub.cpp:11:19: warning: unused variable 'ta' [-Wunused-variable]
   11 |         long long ta=j-i+1;
      |                   ^~
ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:44:19: warning: unused variable 'mx' [-Wunused-variable]
   44 |         long long mx=1;
      |                   ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 0 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 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 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 0 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 0 ms 340 KB Output is correct
9 Correct 0 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 0 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 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 340 KB Output is correct
26 Correct 1 ms 388 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 3 ms 596 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 13 ms 2228 KB Output is correct
4 Correct 13 ms 3264 KB Output is correct
5 Correct 7 ms 1600 KB Output is correct
6 Correct 7 ms 1612 KB Output is correct
7 Correct 11 ms 3028 KB Output is correct
8 Correct 13 ms 3044 KB Output is correct
9 Correct 8 ms 1492 KB Output is correct
10 Correct 6 ms 1492 KB Output is correct
11 Correct 12 ms 3260 KB Output is correct
12 Correct 14 ms 3284 KB Output is correct
13 Correct 7 ms 1620 KB Output is correct
14 Correct 11 ms 1628 KB Output is correct
15 Correct 8 ms 2492 KB Output is correct
16 Correct 9 ms 2516 KB Output is correct
17 Correct 11 ms 2996 KB Output is correct
18 Correct 14 ms 2900 KB Output is correct
19 Correct 11 ms 3116 KB Output is correct
20 Correct 14 ms 3208 KB Output is correct