Submission #418394

# Submission time Handle Problem Language Result Execution time Memory
418394 2021-06-05T10:39:40 Z temurbek_khujaev Rice Hub (IOI11_ricehub) C++17
58 / 100
24 ms 1484 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;


int besthub(int R, int L, int X[], long long B) {
    int ans = 0;
    vector<long long> pref(R, 0);
    for (int i = 0; i < R; i++) {
        pref[i] = i == 0 ? X[0] : (pref[i - 1] + X[i]);
    }
    for (int i = 0; i < R; i++) {
        int l = 1, r = R;
        while (l <= r) {
            int m = (l + r) >> 1;
            int left = i - m / 2 + 1;
            int right = i + (m + 1) / 2;
            bool good = false;
            if (left >= 0 && right < R) {
                long long d1 = pref[right] - pref[i] - (right - i) * 1ll * X[i];
                long long d2 = 1ll * X[i] * (i - left + 1) - pref[i] + (left == 0 ? 0 : pref[left - 1]);
                good = d1 + d2 <= B;
            }


            if (good) {
                l = m + 1;
                ans = max(ans, m);
            } else r = m - 1;
        }


    }


    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 460 KB Output is correct
2 Correct 4 ms 460 KB Output is correct
3 Correct 23 ms 1404 KB Output is correct
4 Correct 24 ms 1484 KB Output is correct
5 Correct 13 ms 824 KB Output is correct
6 Correct 10 ms 844 KB Output is correct
7 Correct 21 ms 1484 KB Output is correct
8 Correct 21 ms 1484 KB Output is correct
9 Correct 9 ms 844 KB Output is correct
10 Correct 10 ms 844 KB Output is correct
11 Correct 22 ms 1396 KB Output is correct
12 Correct 23 ms 1484 KB Output is correct
13 Correct 10 ms 844 KB Output is correct
14 Correct 10 ms 892 KB Output is correct
15 Correct 17 ms 1188 KB Output is correct
16 Correct 18 ms 1100 KB Output is correct
17 Correct 20 ms 1356 KB Output is correct
18 Correct 20 ms 1356 KB Output is correct
19 Correct 21 ms 1388 KB Output is correct
20 Correct 21 ms 1348 KB Output is correct