Submission #551198

# Submission time Handle Problem Language Result Execution time Memory
551198 2022-04-20T05:17:15 Z alirezasamimi100 Rice Hub (IOI11_ricehub) C++17
100 / 100
21 ms 1748 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define pb push_back
int besthub(int R, int L, int X[], ll B){
    ll p=0,ans=0,c=0,m=0;
    for(ll i=0; i<R; i++){
        if(m-i<p-m){
            c+=(X[m+1]-X[m])*(p-m-(m-i+1));
            m++;
        }
        while(c<=B && p<R){
            p++;
            if(p!=R){
                c+=X[p]-X[m];
                if(m-i<p-m){
                    c+=(X[m+1]-X[m])*(p-m-(m-i+1));
                    m++;
                }
            }else{
                ans=max(ans,p-i);
                return ans;
            }
        }
        ans=max(ans,p-i);
        c-=X[m]-X[i];
    }
    return ans;

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 308 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 312 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 312 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 1 ms 352 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 12 ms 1732 KB Output is correct
4 Correct 21 ms 1672 KB Output is correct
5 Correct 5 ms 840 KB Output is correct
6 Correct 5 ms 752 KB Output is correct
7 Correct 11 ms 1364 KB Output is correct
8 Correct 10 ms 1444 KB Output is correct
9 Correct 5 ms 684 KB Output is correct
10 Correct 5 ms 724 KB Output is correct
11 Correct 11 ms 1748 KB Output is correct
12 Correct 12 ms 1748 KB Output is correct
13 Correct 6 ms 852 KB Output is correct
14 Correct 5 ms 832 KB Output is correct
15 Correct 8 ms 1364 KB Output is correct
16 Correct 9 ms 1364 KB Output is correct
17 Correct 10 ms 1492 KB Output is correct
18 Correct 10 ms 1512 KB Output is correct
19 Correct 15 ms 1620 KB Output is correct
20 Correct 11 ms 1620 KB Output is correct