Submission #744073

# Submission time Handle Problem Language Result Execution time Memory
744073 2023-05-18T07:52:49 Z vjudge1 Rice Hub (IOI11_ricehub) C++17
0 / 100
3 ms 468 KB
#include "ricehub.h"

int besthub(int R, int L, int X[], long long B)
{
    long long qs[R];
    qs[0] = 0;
    long long ans;
    for(int i=1;i<=R;++i)
    {
        qs[i] = qs[i-1]+X[i-1];
    }
    long long l = 1,r = 5;
    while(l <= r)
    {
        long long mid = (l+r)/2;
        bool can = false;
        for(int med = (mid+1)/2;med <= r-mid/2;++med)
        {
            long long sumLeft = qs[med-(med%2==1)]-qs[med-mid/2+(med%2==0)];
            long long sumRight = qs[med+mid/2]-qs[med+1];
            long long cost = sumRight - sumLeft;
            if(cost <= B)
            {
                can = true;
                break;
            }
        }
        if(can)
        {
            ans = mid;
            l = mid+1;
        }
        else r = mid-1;
    }
    return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:35:12: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |     return ans;
      |            ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -