Submission #969909

# Submission time Handle Problem Language Result Execution time Memory
969909 2024-04-25T19:28:18 Z urieg Rice Hub (IOI11_ricehub) C++17
0 / 100
2 ms 604 KB

#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
typedef long long ll;
/// for moondance

int besthub(int R, int L, int X[], long long B){

    vector<ll>x(R), p(R);
    for(int i=0;i<R;i++){
        x[i] = X[i];
        p[i] = x[i];
        if(i)p[i] += p[i-1];
    }


    int ans = 1;
    ll sum = 0;
    int l = 0, r = 0;
    for(int i =0;i<R;i++){
        r = max(r, i);
        sum = p[r]-p[i] - p[i]*(r-i);
        sum += p[i]*(i-l+1) - (p[i]-(!l ? 0 : p[l-1]));
        while(sum > B){
            l++;
            sum = p[r]-p[i] - p[i]*(r-i);
            sum += p[i]*(i-l+1) - (p[i]-(!l ? 0 : p[l-1]));
        }

        while(r<R){
            ll new_sum = p[r+1]-p[i] - p[i]*(r+1-i);
            new_sum += p[i]*(i-l+1) - (p[i]-(!l ? 0 : p[l-1]));
            if(new_sum <= B){
                sum = new_sum;
                r++;
            }
            else{
                break;
            }
        }
        ans = max(ans, r-l+1);
    }
    return ans;
}




# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -