답안 #255141

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
255141 2020-07-31T10:35:37 Z SamAnd 쌀 창고 (IOI11_ricehub) C++17
100 / 100
19 ms 2944 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int N = 100005;

int n, d;
int x[N];
ll b;

ll p[N];

bool stg(int q)
{
    for (int l = 1; l <= n - q + 1; ++l)
    {
        int r = l + q - 1;
        int m = (l + r) / 2;

        ll yb = 0;
        yb += (m - l + 1) * 1LL * x[m];
        yb -= (p[m] - p[l - 1]);
        yb += (p[r] - p[m - 1]);
        yb -= (r - m + 1) * 1LL * x[m];
        if (yb <= b)
            return true;
    }
    return false;
}

int solv()
{
    for (int i = 1; i <= n; ++i)
        p[i] = p[i - 1] + x[i];
    int ans = 0;
    int l = 1, r = n;
    while (l <= r)
    {
        int m = (l + r) / 2;
        if (stg(m))
        {
            ans = m;
            l = m + 1;
        }
        else
        {
            r = m - 1;
        }
    }
    return ans;
}

int besthub(int R, int L, int X[], ll B)
{
    n = R;
    d = L;
    for (int i = 1; i <= n; ++i)
        x[i] = X[i - 1];
    b = B;
    return solv();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 0 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 0 ms 384 KB Output is correct
27 Correct 0 ms 384 KB Output is correct
28 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 768 KB Output is correct
2 Correct 4 ms 768 KB Output is correct
3 Correct 17 ms 2936 KB Output is correct
4 Correct 16 ms 2944 KB Output is correct
5 Correct 10 ms 1408 KB Output is correct
6 Correct 8 ms 1408 KB Output is correct
7 Correct 14 ms 2688 KB Output is correct
8 Correct 14 ms 2688 KB Output is correct
9 Correct 8 ms 1408 KB Output is correct
10 Correct 9 ms 1408 KB Output is correct
11 Correct 19 ms 2936 KB Output is correct
12 Correct 18 ms 2944 KB Output is correct
13 Correct 9 ms 1440 KB Output is correct
14 Correct 9 ms 1536 KB Output is correct
15 Correct 13 ms 2304 KB Output is correct
16 Correct 13 ms 2304 KB Output is correct
17 Correct 16 ms 2724 KB Output is correct
18 Correct 16 ms 2688 KB Output is correct
19 Correct 18 ms 2816 KB Output is correct
20 Correct 17 ms 2808 KB Output is correct