Submission #284516

# Submission time Handle Problem Language Result Execution time Memory
284516 2020-08-27T14:34:08 Z Basilhijaz Rice Hub (IOI11_ricehub) C++17
0 / 100
5 ms 768 KB
#include "ricehub.h"

using namespace std;
typedef long long ll;


int besthub(int R, int L, int X[], long long B)
{
    ll pre[R + 1];
    int X2[R + 1];
    X2[0] = 0;
    pre[0] = 0;
    for(int i = 1; i <= R; i++){
        X2[i] = X[i - 1];
        pre[i] = X2[i] + pre[i - 1];
    }
    int lo = 0; int hi = R;
    while(lo < hi){
        ll mid = (lo + hi + 1)/2;
        bool can = 0;
        for(int i = 1; i + mid - 1 <= R; i++){
            ll sum = 0;
            ll nos = (i + i + mid - 1)/2;
            ll k1 = nos - i - 1;
            sum += X2[nos]*k1 - (pre[nos - 1] - pre[i - 1]);
            ll k2 = (i + i + mid - 1) - nos - 1;
            sum += (pre[i + i + mid - 1] - pre[nos]) - X2[nos]*k2;
            if(sum <= B){
                can = 1;
                break;
            }
        }
        if(can){
            lo = mid;
        }
        else{
            hi = mid - 1;
        }
    }
    return lo;
}

# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 768 KB Output isn't correct
2 Halted 0 ms 0 KB -