Submission #374255

# Submission time Handle Problem Language Result Execution time Memory
374255 2021-03-07T02:02:33 Z ijxjdjd Rice Hub (IOI11_ricehub) C++14
100 / 100
20 ms 1772 KB
#include "ricehub.h"

using ll = long long;
int besthub(int R, int L, int X[], ll B)
{
    int low = 1;
    int high = R;
    while (low < high) {
        int mid = (low + high+1)/2;
        int l = 0;
        int r = 0;
        int m = (mid-1)/2;
        bool good = false;
        ll bot = 0;
        ll top = 0;
        while (r < mid) {
            if (r < m) {
                bot += X[r];
            }
            else if (r > m) {
                top += X[r];
            }
            r++;
        }
        r--;
        if ((m-l)*X[m]-bot + top-(r-m)*X[m] <= B) {
            good = true;
        }
        while (r+1< R) {
            bot -= X[l];
            top += X[r+1];
            bot += X[m];
            top -= X[m+1];
            r++;
            l++;
            m++;
            if ((m-l)*X[m]-bot + top-(r-m)*X[m] <= B) {
                good = true;
            }
        }
        if (good) {
            low = mid;
        }
        else {
            high = mid-1;
        }
    }
    return low;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 0 ms 368 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 0 ms 376 KB Output is correct
17 Correct 0 ms 364 KB Output is correct
18 Correct 0 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 492 KB Output is correct
2 Correct 4 ms 492 KB Output is correct
3 Correct 17 ms 1772 KB Output is correct
4 Correct 17 ms 1772 KB Output is correct
5 Correct 9 ms 876 KB Output is correct
6 Correct 9 ms 876 KB Output is correct
7 Correct 15 ms 1644 KB Output is correct
8 Correct 20 ms 1516 KB Output is correct
9 Correct 8 ms 748 KB Output is correct
10 Correct 10 ms 748 KB Output is correct
11 Correct 17 ms 1772 KB Output is correct
12 Correct 17 ms 1772 KB Output is correct
13 Correct 9 ms 876 KB Output is correct
14 Correct 9 ms 876 KB Output is correct
15 Correct 13 ms 1388 KB Output is correct
16 Correct 14 ms 1388 KB Output is correct
17 Correct 15 ms 1664 KB Output is correct
18 Correct 15 ms 1644 KB Output is correct
19 Correct 16 ms 1644 KB Output is correct
20 Correct 16 ms 1644 KB Output is correct