Submission #493525

# Submission time Handle Problem Language Result Execution time Memory
493525 2021-12-11T21:17:34 Z AlexRex0 Rice Hub (IOI11_ricehub) C++14
0 / 100
3 ms 716 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

long long int pos[100002];
long long int acumulado[100002];

long long int cal(int l, int r, int m){
    long long int suma = 0;
    if(r > m){
        suma+= (acumulado[r] - acumulado[m]) - ((r - m) * pos[m]);
    }
    if(l < m){
        suma+= (acumulado[m - 1] - acumulado[l - 1]) - ((m - l) * pos[m]);
    }
    return suma;
}

int besthub(int R, int L, int X[], long long B)
{
    for(int i = 0; i < R; ++i){
        pos[i + 1] = X[i];
        acumulado[i + 1] = acumulado[i] + pos[i + 1];
    }

    int l = 1, r = 1, m = 1, ans = 1, n = R;
    while(l < n || r < n){
        m = (l + r) / 2;
        if(cal(l, r, m) <= B){
            ans = max(ans, r - l + 1);
            if(r < n){
                r++;
            }else{
                l++;
            }
        }else{
            l++;
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 296 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -