Submission #235556

# Submission time Handle Problem Language Result Execution time Memory
235556 2020-05-28T14:21:36 Z Toirov_Sadi Rice Hub (IOI11_ricehub) C++17
0 / 100
8 ms 768 KB
#include<bits/stdc++.h>
#include "ricehub.h"

using namespace std;

int besthub(int n, int L, int X[], long long B){
    int res = 0;

    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] - 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;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:7:9: warning: unused variable 'res' [-Wunused-variable]
     int res = 0;
         ^~~
# 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 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 768 KB Output isn't correct
2 Halted 0 ms 0 KB -