Submission #302362

# Submission time Handle Problem Language Result Execution time Memory
302362 2020-09-18T16:00:56 Z UserIsUndefined Rice Hub (IOI11_ricehub) C++14
0 / 100
4 ms 512 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;


int besthub(int R, int L, int X[], long long B)
{

    int low = 0;

    int high = R*2;


    while(low < high){
        int mid = (high+low)/2;

//        cout << mid << " " << low << " " << high << endl;


        long long sum = 0;

        long long now = X[mid/2];

        long long pluss = mid - mid/2 - 1;

        long long mines = mid - pluss + 1;




        for (int i = 0 ; i < mid ; i++){
            sum+= llabs(now - X[i]);
        }

        if (sum <= B){
            low = mid + 1;
            continue;
        }

        int good = false;


        for (int i = now + 1 ; i + pluss < R ; i++){
            int bye = X[i - mines];
            sum-= llabs(X[i-1] - bye);
            int hello = X[i + pluss];
            sum+= llabs(X[i] - hello);

            sum+= llabs(X[i] - X[i-1])*mines;

            sum-= llabs(X[i] - X[i-1])*(pluss - 1);

            if (sum <= B){
                low = mid + 1;
                good = true;
                break;
            }

        }

        if (good)continue;

        high = mid - 1;






    }





    return low;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -