Submission #1019608

# Submission time Handle Problem Language Result Execution time Memory
1019608 2024-07-11T05:00:09 Z Luvidi Rice Hub (IOI11_ricehub) C++17
0 / 100
1000 ms 2652 KB
#include "ricehub.h"

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back

int besthub(int n, int L, int X[], long long b)
{
    ll a[n],ans,l=0,r=0,s=0;
    for(int i=0;i<n;i++)a[i]=X[i];
    while(r+1<n&&s+a[r+1]-a[0]<=b){
        r++;
        s+=a[r]-a[0];
    }
    ans=r-l+1;
    for(int i=1;i<n;i++){
        s-=(a[i]-a[i-1])*(r-i+1);
        s+=(a[i]-a[i-1])*(i-l);
        while(r>=i&&a[i]-a[l]>a[r]-a[i]){
            s-=a[i]-a[l];
            l++;
        }
        if(r<i){
            l=r=i;
            s=0;
        }
        while(s>b){
            if(r-1>=i&&(l==i||a[r-1]-a[i]<=a[i]-a[l+1])){
                s-=a[r]-a[i];
                r--;
            }else{
                s-=a[i]-a[l];
                l++;
            }
        }
        while(s<b&&(l||r+1<n)){
            if(r+1<n&&(!l||a[r+1]-a[l]<=a[i]-a[l-1])){
                if(s+a[r+1]-a[i]>b)break;
                r++;
                s+=a[r]-a[i];
            }else{
                if(s+a[i]-a[l-1]>b)break;
                l--;
                s+=a[i]-a[l];
            }
        }
        ans=max(ans,r-l+1);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 452 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 448 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Incorrect 1 ms 372 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 452 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 452 KB Output is correct
13 Correct 1 ms 416 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 604 KB Output is correct
2 Correct 4 ms 604 KB Output is correct
3 Execution timed out 1090 ms 2652 KB Time limit exceeded
4 Halted 0 ms 0 KB -