Submission #969904

# Submission time Handle Problem Language Result Execution time Memory
969904 2024-04-25T19:16:13 Z urieg Rice Hub (IOI11_ricehub) C++17
0 / 100
2 ms 600 KB

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

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++){
        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){
            r++;
            ll new_sum = p[r]-p[i] - p[i]*(r-i);
            new_sum += p[i]*(i-l+1) - (p[i]-(!l ? 0 : p[l-1]));
            if(new_sum <= B)sum = new_sum;
            else{
                r--;
                break;
            }
        }
        ans = max(ans, r-l+1);
    }

    return ans;
}




# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 444 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 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 2 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -