Submission #410825

# Submission time Handle Problem Language Result Execution time Memory
410825 2021-05-23T19:29:06 Z LouayFarah Rice Hub (IOI11_ricehub) C++14
0 / 100
39 ms 332 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
    long long b;
    int sum = 0;
    for(int x = 1; x<=L; x++)
    {
        b = B;
        int l, r;
        l = lower_bound(X, X+R, x)-X+-1;
        r = l+2;
        int res = 0;
        while((r<R||l>=0)&&(b>=0))
        {
            if(l<0)
            {
                res++;
                b-=abs(x-X[r]);
                r++;
            }
            else if(r==R)
            {
                res++;
                b-=abs(x-X[l]);
                l--;
            }
            else if(abs(X[l]-x)<=abs(X[r]-x))
            {
                res++;
                b-=abs(x-X[l]);
                l--;
            }
            else if(abs(X[l]-x)>abs(X[r]-x))
            {
                res++;
                b-=abs(x-X[r]);
                r++;
            }
        }
        sum = max(sum , res);
    }

    return sum;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
2 Incorrect 2 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 39 ms 332 KB Output is correct
2 Incorrect 39 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -