Submission #111798

# Submission time Handle Problem Language Result Execution time Memory
111798 2019-05-16T07:52:58 Z Mercenary Rice Hub (IOI11_ricehub) C++14
0 / 100
5 ms 384 KB
#include "ricehub.h"
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

bool Chk(int X[] , int R , ll B , int ask){
    int l = 0 , h = ask - 1;
    ll sum = 0;
    ll suml = 0;
    for(int i = 0 ; i < h ; ++i){
        sum += X[i];
        if(i <= (l + h) / 2)suml += X[i];
    }
    while(true){
        if(((ask + 1) / 2) * (ll)X[(l + h) / 2] - suml + sum - suml - (ask / 2) * (ll)X[(l + h) / 2] <= B)return 1;
        if(h == R - 1)break;
        sum += -X[l] + X[h + 1];
        suml += -X[l] + X[(l + h) / 2 + 1];
        ++l;++h;
    }
    return 0;
}

int besthub(int R, int L, int X[], long long B)
{
    int l = 1;
    int h = R + 1;
    while(l <= h){
        ll mid = l + h >> 1;
        if(Chk(X , R , B , mid))l = mid + 1;
        else h = mid - 1;
    }
    cerr << Chk(X,R,B,1);
    return h;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:30:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         ll mid = l + h >> 1;
                  ~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 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 -