Submission #1049376

# Submission time Handle Problem Language Result Execution time Memory
1049376 2024-08-08T17:31:59 Z AndreasK Rice Hub (IOI11_ricehub) C++14
100 / 100
13 ms 4528 KB
#include <bits/stdc++.h>
using namespace std;
 
#define designed ios_base::sync_with_stdio(0);
#define by cin.tie(0);
#define AndreasK cout.tie(0);
//#define int long long
#define ii pair <int,int>
#define vi vector <int>
#define iii pair <int,ii>
#define vii vector <ii>
#define vc vector <char>
#define vb vector <bool>
 
int besthub(int R, int L, int X[], long long B)
{
    #define int long long
    int pre[R];
    int ttl=0;
    for (int c=0;c<R;c++){
        ttl+=X[c];
        pre[c]=ttl;
    }
    int mx=0;
    for (int r=0;r<R;r++){
        int ll=r,rr=(R-1+r)/2,mid;
        while (ll<=rr){
            mid=(ll+rr)/2;
            int f=0;
            if (r==0){
                f+=(mid-r+1)*X[mid]-pre[mid];
            }
            else{
                f+=(mid-r+1)*X[mid]-pre[mid]+pre[r-1];
            }
            int f1;
            if (mid!=0){
                f1=f+pre[mid+(mid-r)]-pre[mid-1]-(mid-r+1)*X[mid];
            }
            else{
                f1=f+pre[mid+(mid-r)]-(mid-r+1)*X[mid];
            }
            int f2=LLONG_MAX;
            if (mid+mid-r+1<R){
                if (mid!=0){
                    f2=f+pre[mid+(mid-r+1)]-pre[mid-1]-(mid-r+2)*X[mid];
                }
                else{
                    f2=f+pre[mid+(mid-r+1)]-(mid-r+2)*X[mid];
                }
            }
            if (f1<=B){
                mx=max(mx,2*(mid-r)+1);
            }
            if (f2<=B){
                mx=max(mx,2*(mid-r)+2);
            }
            if (f1<=B){
                ll=mid+1;
            }
            else
                rr=mid-1;
        }
    }
    return mx;
}
 
/*int32_t main(){
    designed by AndreasK
    int R,L,B;
    cin>>R>>L>>B;
    int X[R];
    for (auto &c:X)
        cin>>c;
    cout<<besthub(R,L,X,B);
return 0;}*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 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 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 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 1 ms 348 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 0 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 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 376 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 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 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
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 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 348 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 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 344 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 2 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 12 ms 3452 KB Output is correct
4 Correct 13 ms 3348 KB Output is correct
5 Correct 5 ms 3164 KB Output is correct
6 Correct 5 ms 3164 KB Output is correct
7 Correct 12 ms 4068 KB Output is correct
8 Correct 12 ms 4224 KB Output is correct
9 Correct 6 ms 3164 KB Output is correct
10 Correct 6 ms 3148 KB Output is correct
11 Correct 13 ms 4528 KB Output is correct
12 Correct 13 ms 4448 KB Output is correct
13 Correct 6 ms 3420 KB Output is correct
14 Correct 6 ms 3420 KB Output is correct
15 Correct 10 ms 4044 KB Output is correct
16 Correct 10 ms 3932 KB Output is correct
17 Correct 12 ms 4188 KB Output is correct
18 Correct 11 ms 4188 KB Output is correct
19 Correct 13 ms 4404 KB Output is correct
20 Correct 12 ms 4328 KB Output is correct