Submission #834688

# Submission time Handle Problem Language Result Execution time Memory
834688 2023-08-22T17:10:21 Z HaroldVemeno Rice Hub (IOI11_ricehub) C++17
100 / 100
11 ms 1816 KB
#include "ricehub.h"
#include <bits/stdc++.h>

#ifdef GUDEB
    #define D(x) cerr << #x << ": " << (x) << '\n';
    #define ifdeb if(true)
#else
    #define D(x) ;
    #define ifdeb if(false)
#endif

#define all(x) begin(x), end(x)

using namespace std;
using ull = unsigned long long;
using ll = long long;
// #define int ll;

int besthub(int R, int L, int X[], long long B) {

    int l = 0;
    int m = 0;
    int r = 0;
    ll c = 0;
    int best = 1;


    while(r < R) {
        ++r;
        c += X[r-1] - X[m];
        D(l)
        D(m)
        D(r)
        D(c)
        while(m < (l+r)/2) {
            c += 1ll*(X[m+1] - X[m])*(2*m-l-r+2);
            ++m;
        }
        while(c > B) {
            c -= X[m] - X[l];
            ++l;
            while(m < (l+r)/2) {
                c += 1ll*(X[m+1] - X[m])*(2*m-l-r+2);
                ++m;
            }
        }
        best = max(best, r-l);
    }

    return best;
}
# 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 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 308 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 312 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 240 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 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 316 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 348 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 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 9 ms 1708 KB Output is correct
4 Correct 9 ms 1724 KB Output is correct
5 Correct 6 ms 852 KB Output is correct
6 Correct 6 ms 776 KB Output is correct
7 Correct 11 ms 1460 KB Output is correct
8 Correct 8 ms 1424 KB Output is correct
9 Correct 4 ms 804 KB Output is correct
10 Correct 4 ms 724 KB Output is correct
11 Correct 9 ms 1816 KB Output is correct
12 Correct 9 ms 1772 KB Output is correct
13 Correct 4 ms 852 KB Output is correct
14 Correct 5 ms 852 KB Output is correct
15 Correct 7 ms 1332 KB Output is correct
16 Correct 7 ms 1332 KB Output is correct
17 Correct 9 ms 1492 KB Output is correct
18 Correct 8 ms 1492 KB Output is correct
19 Correct 8 ms 1636 KB Output is correct
20 Correct 9 ms 1620 KB Output is correct