Submission #235559

# Submission time Handle Problem Language Result Execution time Memory
235559 2020-05-28T14:23:45 Z Toirov_Sadi Rice Hub (IOI11_ricehub) C++17
0 / 100
7 ms 640 KB
#include<bits/stdc++.h>
#include "ricehub.h"

using namespace std;

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

    vector<long long> p(n, 0);
    for(int i = 0; i < n; i ++){
        if(i > 0) p[i] = p[i - 1];
        p[i] += X[i];
    }
    int l = 0, r = n;
    while(l < r){
        int m = (l + r) / 2;
        /// can m ?
        bool can = false;

        for(int i = 0; i + m < n; i ++){
            int l1 = i, r1 = i + m;
            int mid = (l1 + r1) / 2;
            int x = m / 2;
            int y = m - (m / 2);
            long long cur = x * 1ll * X[i] - (p[mid] - (l1 == 0 ? 0 : p[l1 - 1]));
            cur += (p[r1] - p[mid]) - y * 1ll * X[i];
            if(cur <= B) can = true;
        }

        if(can == true){
            l = m + 1;
        }
        else{
            r = m;
        }

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