Submission #235546

#TimeUsernameProblemLanguageResultExecution timeMemory
235546Toirov_SadiRice Hub (IOI11_ricehub)C++17
68 / 100
1088 ms1792 KiB
#include<bits/stdc++.h>
#include "ricehub.h"

using namespace std;

int besthub(int n, int L, int X[], long long B){
    int res = 0;
    for(int i = 0; i < n; i ++){
        int l = i, r = i;
        long long ans = 0;
        while(l >= 0 && r < n){
            int x = INT_MAX;
            int y = INT_MAX;
            if(l > 0) x = X[i] - X[l - 1];
            if(r < n - 1) y = X[r + 1] - X[i];

            if(x < y && ans + x <= B) l --, ans += x;
            else if(y < x && ans + y <= B) r ++, ans += y;
            else if(x == y && x != INT_MAX && ans + x <= B) l --, ans += x;
            else break;
        }
        res = max(res, r - l + 1);
    }
    return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...