Submission #235538

# Submission time Handle Problem Language Result Execution time Memory
235538 2020-05-28T13:01:43 Z Toirov_Sadi Rice Hub (IOI11_ricehub) C++17
0 / 100
1000 ms 528 KB
#include<bits/stdc++.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){
            if(l > 0 && r < n - 1){
                int x = X[i] - X[l - 1];
                int 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(l > 0 && ans + (X[i] - X[l - 1]) <= B){
                ans += (X[i] - X[l - 1]);
                l --;
            }
            else if(r < n - 1 && ans + (X[r + 1] - X[i]) <= B){
                ans += (X[r + 1] - X[i]);
                r ++;
            }
            else break;
        }
        res = max(res, r - l + 1);
    }
    return res;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 528 KB Time limit exceeded
2 Halted 0 ms 0 KB -