답안 #537737

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
537737 2022-03-15T12:44:27 Z timreizin 쌀 창고 (IOI11_ricehub) C++17
100 / 100
22 ms 2260 KB
#include "ricehub.h"
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;

int besthub(int n, int , 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 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
# 결과 실행 시간 메모리 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
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 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 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 0 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
# 결과 실행 시간 메모리 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 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 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 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 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 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 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 596 KB Output is correct
2 Correct 4 ms 596 KB Output is correct
3 Correct 22 ms 2260 KB Output is correct
4 Correct 21 ms 2260 KB Output is correct
5 Correct 9 ms 1188 KB Output is correct
6 Correct 9 ms 1168 KB Output is correct
7 Correct 19 ms 2260 KB Output is correct
8 Correct 20 ms 2260 KB Output is correct
9 Correct 10 ms 1236 KB Output is correct
10 Correct 12 ms 1236 KB Output is correct
11 Correct 21 ms 2144 KB Output is correct
12 Correct 22 ms 2260 KB Output is correct
13 Correct 10 ms 1240 KB Output is correct
14 Correct 9 ms 1288 KB Output is correct
15 Correct 15 ms 1748 KB Output is correct
16 Correct 15 ms 1752 KB Output is correct
17 Correct 20 ms 2024 KB Output is correct
18 Correct 20 ms 2052 KB Output is correct
19 Correct 20 ms 2116 KB Output is correct
20 Correct 22 ms 2164 KB Output is correct