답안 #537733

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
537733 2022-03-15T12:43:27 Z timreizin 쌀 창고 (IOI11_ricehub) C++17
100 / 100
24 ms 3328 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 292 KB Output is correct
3 Correct 1 ms 216 KB Output is correct
4 Correct 0 ms 224 KB Output is correct
5 Correct 0 ms 224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 224 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 0 ms 224 KB Output is correct
4 Correct 0 ms 224 KB Output is correct
5 Correct 1 ms 224 KB Output is correct
6 Correct 0 ms 224 KB Output is correct
7 Correct 0 ms 224 KB Output is correct
8 Correct 1 ms 216 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 216 KB Output is correct
11 Correct 1 ms 216 KB Output is correct
12 Correct 0 ms 216 KB Output is correct
13 Correct 1 ms 216 KB Output is correct
14 Correct 1 ms 216 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 300 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 0 ms 212 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 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 296 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 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 212 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 1 ms 308 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 304 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 212 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 340 KB Output is correct
22 Correct 1 ms 324 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 304 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 1 ms 316 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 2 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 600 KB Output is correct
2 Correct 4 ms 748 KB Output is correct
3 Correct 22 ms 3328 KB Output is correct
4 Correct 24 ms 3248 KB Output is correct
5 Correct 9 ms 1624 KB Output is correct
6 Correct 10 ms 1624 KB Output is correct
7 Correct 22 ms 3024 KB Output is correct
8 Correct 20 ms 3036 KB Output is correct
9 Correct 10 ms 1496 KB Output is correct
10 Correct 10 ms 1596 KB Output is correct
11 Correct 22 ms 3280 KB Output is correct
12 Correct 22 ms 3316 KB Output is correct
13 Correct 10 ms 1624 KB Output is correct
14 Correct 10 ms 1620 KB Output is correct
15 Correct 16 ms 2448 KB Output is correct
16 Correct 16 ms 2500 KB Output is correct
17 Correct 21 ms 2912 KB Output is correct
18 Correct 19 ms 2896 KB Output is correct
19 Correct 21 ms 3104 KB Output is correct
20 Correct 21 ms 3168 KB Output is correct