Submission #800677

# Submission time Handle Problem Language Result Execution time Memory
800677 2023-08-01T17:59:41 Z vjudge1 Rice Hub (IOI11_ricehub) C++17
68 / 100
10 ms 2112 KB
#include "ricehub.h"

#include <bits/stdc++.h>
using namespace std;

int P[100101];

int besthub(int R, int L, int X[], long long B) {
        int l = 1, r = R, res = -1;
        for (int i = 0; i < R; i++) P[i + 1] = P[i] + X[i];
        while (l <= r) {
                int mid = l + r >> 1;
                bool ok = 0;
                for (int i = mid - 1, j = 0; i < R; i++) {
                        while (j - (i - mid + 1) < i - j) j++;
                        int median = X[j];
                        long long LL = P[j] - P[i - mid + 1];
                        long long RR = P[i + 1] - P[j];
                        LL = 1ll * median * (j - i + mid - 1) - LL;
                        RR = RR - 1ll * median * (i + 1 - j);
                        if (LL + RR <= B) ok = 1;
                }
                if (ok) {
                        res = mid;
                        l = mid + 1;
                } else {
                        r = mid - 1;
                }
        }
        return res;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:12:29: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   12 |                 int mid = l + r >> 1;
      |                           ~~^~~
# 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 0 ms 312 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 1 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 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 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 1 ms 308 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 316 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 340 KB Output is correct
18 Correct 1 ms 312 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 308 KB Output is correct
22 Correct 0 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 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 316 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 0 ms 212 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 308 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 316 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 292 KB Output is correct
19 Correct 0 ms 312 KB Output is correct
20 Correct 1 ms 316 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 320 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 340 KB Output is correct
26 Correct 1 ms 364 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 596 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 10 ms 2112 KB Output is correct
4 Incorrect 10 ms 2100 KB Output isn't correct
5 Halted 0 ms 0 KB -