답안 #485236

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
485236 2021-11-06T15:41:29 Z chungdinh 쌀 창고 (IOI11_ricehub) C++17
68 / 100
1000 ms 1736 KB
#include <cstdio>
#include <string>
#include <queue>
#include <iostream>

using namespace std;

#define endl "\n"
#define cntbit(x) __builtin_popcount(x)
#define on(b, x) (b & (1 << x))
#define all(x) x.begin(), x.end()
#define gcd __gcd
#define ll long long
#define ii pair<int, int>

#define cost(l, r) a[r] - a[l]

const int N = 3e3 + 5;
const ll MOD = 998244353;
const int iINF = 1e9;
const ll INF = 1e18;

int n, l;
ll b;
int a[N];

int besthub(int n, int l, int a[], ll b) {
    int res = 0;

    for (int i = 0; i < n; i++) {
        int l = i - 1, r = i + 1;

        int subres = 0;
        ll left = b;

        while (l >= 0 || r <= n - 1) {
            if (l < 0) {
                if (cost(i, r) > left) break;
                subres++;
                left -= cost(i, r);
                r++;
            } else if (r > n - 1) {
                if (cost(l, i) > left) break;
                subres++;
                left -= cost(l, i);
                l--;
            } else {
                ll tt = min(cost(l, i), cost(i, r));
                if (tt > left) break;

                if (cost(l, i) < cost(i, r)) {
                    left -= cost(l, i);
                    l--;
                } else {
                    left -= cost(i, r);
                    r++;
                }
                subres++;
            }
        }

        res = max(res, subres + 1);
    }

    return res;
}
/*
int main() {
    #ifdef CHUNGDINH
    freopen("main.inp", "r", stdin);
    #endif

    scanf("%d%lld%lld",&n,&l,&b);
    for (int i = 0; i < n; i++) scanf("%lld", a + i);

    printf("%d", besthub(n, l, a, b));
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 216 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 304 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 2 ms 308 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 4 ms 204 KB Output is correct
14 Correct 6 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 276 KB Output is correct
17 Correct 3 ms 204 KB Output is correct
18 Correct 5 ms 204 KB Output is correct
19 Correct 4 ms 204 KB Output is correct
20 Correct 4 ms 316 KB Output is correct
21 Correct 4 ms 332 KB Output is correct
22 Correct 5 ms 332 KB Output is correct
23 Correct 74 ms 332 KB Output is correct
24 Correct 68 ms 332 KB Output is correct
25 Correct 97 ms 344 KB Output is correct
26 Correct 98 ms 344 KB Output is correct
27 Correct 29 ms 332 KB Output is correct
28 Correct 29 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 460 KB Output is correct
2 Correct 6 ms 516 KB Output is correct
3 Execution timed out 1090 ms 1736 KB Time limit exceeded
4 Halted 0 ms 0 KB -