답안 #56152

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
56152 2018-07-10T06:20:10 Z aquablitz11 쌀 창고 (IOI11_ricehub) C++14
100 / 100
29 ms 13872 KB
#include <bits/stdc++.h>
#include "ricehub.h"

using namespace std;
using ll = long long;

const int N = 100010;
ll qsl[N], qsr[N];

int besthub(int n, int L, int pos[], ll budget)
{
    for (int i = 1; i <= n; ++i) {
        qsl[i] += qsl[i-1] + pos[i-1];
        qsr[i] = qsr[i-1] + (L - pos[i-1]);
    }

    auto check = [&] (int cnt) {
        for (int l = 1, r = cnt; r <= n; ++l, ++r) {
            int m = (l+r)/2;
            ll d = qsr[m]-qsr[l-1] - (L-pos[m-1])*1ll*(m-l+1);
            d += qsl[r]-qsl[m] - (pos[m-1])*1ll*(r-m);
            if (d <= budget) return true;
        }
        return false;
    };
    int b = 0;
    int e = n;
    while (b < e) {
        int m = (b+e+1)/2;
        if (check(m))
            b = m;
        else
            e = m-1;
    }
    return b;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 432 KB Output is correct
4 Correct 2 ms 636 KB Output is correct
5 Correct 2 ms 636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 636 KB Output is correct
2 Correct 2 ms 636 KB Output is correct
3 Correct 2 ms 636 KB Output is correct
4 Correct 2 ms 636 KB Output is correct
5 Correct 2 ms 636 KB Output is correct
6 Correct 2 ms 636 KB Output is correct
7 Correct 2 ms 636 KB Output is correct
8 Correct 2 ms 636 KB Output is correct
9 Correct 2 ms 636 KB Output is correct
10 Correct 2 ms 636 KB Output is correct
11 Correct 2 ms 636 KB Output is correct
12 Correct 2 ms 636 KB Output is correct
13 Correct 2 ms 636 KB Output is correct
14 Correct 2 ms 636 KB Output is correct
15 Correct 3 ms 636 KB Output is correct
16 Correct 3 ms 640 KB Output is correct
17 Correct 2 ms 640 KB Output is correct
18 Correct 3 ms 640 KB Output is correct
19 Correct 2 ms 640 KB Output is correct
20 Correct 2 ms 640 KB Output is correct
21 Correct 3 ms 640 KB Output is correct
22 Correct 3 ms 640 KB Output is correct
23 Correct 3 ms 640 KB Output is correct
24 Correct 2 ms 640 KB Output is correct
25 Correct 2 ms 640 KB Output is correct
26 Correct 2 ms 640 KB Output is correct
27 Correct 2 ms 640 KB Output is correct
28 Correct 2 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 640 KB Output is correct
2 Correct 3 ms 640 KB Output is correct
3 Correct 3 ms 640 KB Output is correct
4 Correct 3 ms 640 KB Output is correct
5 Correct 2 ms 640 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 3 ms 736 KB Output is correct
9 Correct 3 ms 736 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Correct 3 ms 736 KB Output is correct
12 Correct 2 ms 736 KB Output is correct
13 Correct 3 ms 736 KB Output is correct
14 Correct 4 ms 736 KB Output is correct
15 Correct 2 ms 740 KB Output is correct
16 Correct 3 ms 740 KB Output is correct
17 Correct 4 ms 740 KB Output is correct
18 Correct 3 ms 740 KB Output is correct
19 Correct 3 ms 740 KB Output is correct
20 Correct 3 ms 740 KB Output is correct
21 Correct 4 ms 840 KB Output is correct
22 Correct 3 ms 840 KB Output is correct
23 Correct 3 ms 840 KB Output is correct
24 Correct 4 ms 840 KB Output is correct
25 Correct 4 ms 840 KB Output is correct
26 Correct 4 ms 840 KB Output is correct
27 Correct 4 ms 840 KB Output is correct
28 Correct 4 ms 840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1020 KB Output is correct
2 Correct 9 ms 1136 KB Output is correct
3 Correct 23 ms 2676 KB Output is correct
4 Correct 21 ms 2676 KB Output is correct
5 Correct 14 ms 2676 KB Output is correct
6 Correct 14 ms 2676 KB Output is correct
7 Correct 20 ms 4068 KB Output is correct
8 Correct 22 ms 4840 KB Output is correct
9 Correct 11 ms 4840 KB Output is correct
10 Correct 20 ms 4840 KB Output is correct
11 Correct 29 ms 6588 KB Output is correct
12 Correct 22 ms 7572 KB Output is correct
13 Correct 14 ms 7572 KB Output is correct
14 Correct 16 ms 7572 KB Output is correct
15 Correct 17 ms 8676 KB Output is correct
16 Correct 16 ms 9464 KB Output is correct
17 Correct 20 ms 10656 KB Output is correct
18 Correct 20 ms 11724 KB Output is correct
19 Correct 20 ms 12788 KB Output is correct
20 Correct 20 ms 13872 KB Output is correct