Submission #540819

# Submission time Handle Problem Language Result Execution time Memory
540819 2022-03-21T19:57:05 Z MohamedFaresNebili Rice Hub (IOI11_ricehub) C++14
100 / 100
19 ms 2388 KB
#include <bits/stdc++.h>
#include "ricehub.h"
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
 
        using namespace std;
 
        using ll = long long;
        using ii = pair<ll, ll>;
 
        #define ff first
        #define ss second
        #define pb push_back
 
        const int MOD = 1e9 + 7;
 
        int besthub(int R, int L, int X[], long long B) {
            int res = 0; vector<ll> pref(R, 0);
            for(int l = 0; l < R; l++) {
                pref[l] = X[l];
                if(l) pref[l] += pref[l - 1];
            }
            for(int l = 0; l < R; l++) {
                int curr = 1;
                int lo = l, hi = R - 1;
                while(lo <= hi) {
                    int md = (lo + hi) / 2; int d = (md + l) / 2;
                    ll m = X[d];
                    ll calc = m * (d - l + 1) - 2 * pref[d] - m * (md - d) + pref[md];
                    if(l) calc += pref[l - 1];
                    if(calc <= B) lo = md + 1, curr = max(curr, md - l + 1);
                    else hi = md - 1;
                }
                res = max(res, curr);
            }
            return res;
        }
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 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 312 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 1 ms 212 KB Output is correct
5 Correct 0 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 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 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 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 312 KB Output is correct
26 Correct 1 ms 212 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 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 1 ms 308 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 1 ms 320 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 316 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 344 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 324 KB Output is correct
25 Correct 1 ms 340 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 4 ms 596 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 18 ms 2004 KB Output is correct
4 Correct 17 ms 2024 KB Output is correct
5 Correct 7 ms 1224 KB Output is correct
6 Correct 8 ms 1236 KB Output is correct
7 Correct 17 ms 2028 KB Output is correct
8 Correct 16 ms 1952 KB Output is correct
9 Correct 8 ms 1096 KB Output is correct
10 Correct 8 ms 1108 KB Output is correct
11 Correct 17 ms 2004 KB Output is correct
12 Correct 19 ms 2016 KB Output is correct
13 Correct 8 ms 1244 KB Output is correct
14 Correct 8 ms 1236 KB Output is correct
15 Correct 13 ms 1964 KB Output is correct
16 Correct 13 ms 1960 KB Output is correct
17 Correct 16 ms 2260 KB Output is correct
18 Correct 15 ms 2260 KB Output is correct
19 Correct 17 ms 2388 KB Output is correct
20 Correct 17 ms 2388 KB Output is correct