Submission #1019614

# Submission time Handle Problem Language Result Execution time Memory
1019614 2024-07-11T05:13:15 Z Luvidi Rice Hub (IOI11_ricehub) C++17
100 / 100
14 ms 3420 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=0,pre[n+1];
    pre[0]=0;
    for(int i=0;i<n;i++){
        a[i]=X[i];
        pre[i+1]=pre[i]+a[i];
    }
    for(int i=0;i<n;i++){
        ll l=0,r=min(i,n-1-i);
        while(l<r){
            ll m=(l+r+1)/2;
            if(pre[i+m+1]-pre[i+1]-(pre[i]-pre[i-m])<=b)l=m;
            else r=m-1;
        }
        ans=max(ans,2*l+1);
        l=0,r=min(i+1,n-1-i);
        while(l<r){
            ll m=(l+r+1)/2;
            if(pre[i+m+1]-pre[i+1]-(pre[i+1]-pre[i-m+1])<=b)l=m;
            else r=m-1;
        }
        ans=max(ans,2*l);
        
    }
    return ans;
}
# 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 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 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 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 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 448 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 448 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 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 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 452 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 448 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 964 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 13 ms 3420 KB Output is correct
4 Correct 14 ms 3416 KB Output is correct
5 Correct 7 ms 1628 KB Output is correct
6 Correct 6 ms 1628 KB Output is correct
7 Correct 12 ms 3176 KB Output is correct
8 Correct 12 ms 3164 KB Output is correct
9 Correct 6 ms 1628 KB Output is correct
10 Correct 8 ms 1592 KB Output is correct
11 Correct 13 ms 3420 KB Output is correct
12 Correct 13 ms 3276 KB Output is correct
13 Correct 7 ms 1624 KB Output is correct
14 Correct 7 ms 1628 KB Output is correct
15 Correct 10 ms 2648 KB Output is correct
16 Correct 10 ms 2652 KB Output is correct
17 Correct 11 ms 3028 KB Output is correct
18 Correct 12 ms 3088 KB Output is correct
19 Correct 13 ms 3268 KB Output is correct
20 Correct 13 ms 3164 KB Output is correct