답안 #895804

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
895804 2023-12-30T21:23:11 Z vjudge1 쌀 창고 (IOI11_ricehub) C++17
68 / 100
1000 ms 4184 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

ll psum(int i, int j, vector<ll> prefix) {
    if (i > j) {
        return 0;
    }
    if (i == 0) {
        return prefix[j];
    }
    return prefix[j] - prefix[i - 1];
}

int besthub(int N, int L, int X[], ll B) {
    vector<ll> prefix(N + 1);
    prefix[0] = X[0];
    for (int i = 1; i <= N; i++) {
        prefix[i] = X[i] + prefix[i - 1];
    }
    int ans = 0;
    for (int i = 0, j = 0; i < N; i++) {
        while (j + 1 <= i) {
            int mid = (i + j) / 2;
            ll x = X[mid] * (mid - j + 1) - psum(j, mid, prefix);
            if (mid + 1 <= i) {
                x += psum(mid + 1, i, prefix) - X[mid] * (i - mid);
            }
            if (x <= B) {
                break;
            }
            j++;
        }
        ans = max(ans, i - j + 1);
    }
    return ans;
}

// int main() {
//     ios_base::sync_with_stdio(0);
//     cin.tie(0);
//     cout.tie(0);
//     int R, L;
//     cin >> R >> L;
//     int X[R];
//     for (ll i = 0; i < R; i++) {
//         cin >> X[i];
//     }
//     ll B;
//     cin >> B;
//     cout << besthub(R, L, X, B) << "\n";
// }
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 500 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 18 ms 444 KB Output is correct
22 Correct 18 ms 348 KB Output is correct
23 Correct 10 ms 540 KB Output is correct
24 Correct 12 ms 548 KB Output is correct
25 Correct 11 ms 348 KB Output is correct
26 Correct 11 ms 348 KB Output is correct
27 Correct 13 ms 348 KB Output is correct
28 Correct 13 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 271 ms 700 KB Output is correct
2 Correct 258 ms 856 KB Output is correct
3 Execution timed out 1038 ms 4184 KB Time limit exceeded
4 Halted 0 ms 0 KB -