답안 #508831

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
508831 2022-01-13T21:15:44 Z tabr 쌀 창고 (IOI11_ricehub) C++17
100 / 100
15 ms 1484 KB
#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int besthub(int n, int, int* x, long long b) {
    vector<long long> pref(n + 1);
    for (int i = 0; i < n; i++) {
        pref[i + 1] = pref[i] + x[i];
    }
    int lo = 1;
    int hi = n + 1;
    while (hi - lo > 1) {
        int mid = (hi + lo) / 2;
        int ok = 0;
        for (int i = 0; i + mid <= n; i++) {
            for (int j = max(i, (i + i + mid) / 2 - 1); j <= min(i + mid - 1, (i + i + mid) / 2 + 1); j++) {
                long long c = pref[i + mid] - pref[j] - 1LL * x[j] * (i + mid - j);
                c += 1LL * x[j] * (j - i) - (pref[j] - pref[i]);
                if (c <= b) {
                    ok = 1;
                }
            }
        }
        if (ok) {
            lo = mid;
        } else {
            hi = mid;
        }
    }
    return lo;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 284 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 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 304 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 0 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 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 300 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 304 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 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 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 296 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 2 ms 332 KB Output is correct
22 Correct 2 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 460 KB Output is correct
2 Correct 5 ms 460 KB Output is correct
3 Correct 11 ms 1484 KB Output is correct
4 Correct 11 ms 1484 KB Output is correct
5 Correct 12 ms 844 KB Output is correct
6 Correct 15 ms 844 KB Output is correct
7 Correct 10 ms 1484 KB Output is correct
8 Correct 10 ms 1440 KB Output is correct
9 Correct 12 ms 844 KB Output is correct
10 Correct 11 ms 844 KB Output is correct
11 Correct 11 ms 1484 KB Output is correct
12 Correct 12 ms 1448 KB Output is correct
13 Correct 12 ms 844 KB Output is correct
14 Correct 13 ms 844 KB Output is correct
15 Correct 8 ms 1100 KB Output is correct
16 Correct 8 ms 1100 KB Output is correct
17 Correct 10 ms 1228 KB Output is correct
18 Correct 10 ms 1356 KB Output is correct
19 Correct 11 ms 1412 KB Output is correct
20 Correct 10 ms 1312 KB Output is correct