Submission #537735

# Submission time Handle Problem Language Result Execution time Memory
537735 2022-03-15T12:44:03 Z timreizin Rice Hub (IOI11_ricehub) C++17
100 / 100
27 ms 2260 KB
#include "ricehub.h"
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;

int besthub(int n, int lllll, int X[], ll b)
{
    vector<ll> x(n);
    for (int i = 0; i < n; ++i) x[i] = X[i];
    sort(x.begin(), x.end());
    vector<ll> pref(n);
    partial_sum(x.begin(), x.end(), pref.begin());
    int maxRes = 0;
    for (int i = 0; i < n; ++i)
    {
        int l = 0, r = n - i;
        while (l < r)
        {
            int m = (l + r) >> 1;
            int e = i + m;
            int v = (i + e) >> 1;
            ll sum = pref[e] - pref[v];
            if (v != 0) sum -= pref[v - 1] - (i == 0 ? 0ll : pref[i - 1]);
            if (i % 2 != e % 2) sum -= x[v];
            if (sum <= b) l = m + 1;
            else r = m;

        }
        maxRes = max(maxRes, l);
    }
    return maxRes;
}
# 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 0 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 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
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 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 1 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 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 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 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 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
# 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 1 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 1 ms 212 KB Output is correct
7 Correct 0 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 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 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 0 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 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 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 4 ms 596 KB Output is correct
3 Correct 27 ms 2260 KB Output is correct
4 Correct 21 ms 2220 KB Output is correct
5 Correct 10 ms 1236 KB Output is correct
6 Correct 11 ms 1236 KB Output is correct
7 Correct 19 ms 2260 KB Output is correct
8 Correct 19 ms 2260 KB Output is correct
9 Correct 10 ms 1236 KB Output is correct
10 Correct 11 ms 1236 KB Output is correct
11 Correct 21 ms 2260 KB Output is correct
12 Correct 22 ms 2196 KB Output is correct
13 Correct 9 ms 1288 KB Output is correct
14 Correct 9 ms 1236 KB Output is correct
15 Correct 15 ms 1764 KB Output is correct
16 Correct 15 ms 1640 KB Output is correct
17 Correct 19 ms 2056 KB Output is correct
18 Correct 22 ms 2004 KB Output is correct
19 Correct 20 ms 2132 KB Output is correct
20 Correct 19 ms 2132 KB Output is correct