답안 #902471

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
902471 2024-01-10T13:04:57 Z thinknoexit Feast (NOI19_feast) C++17
59 / 100
101 ms 10032 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int a[300300], n;
ll qs[300300];
ll dp[300300];
int cnt[300300];
void cal(ll mid) {
    pair<ll, int> mx(0ll, 0);
    for (int i = 1;i <= n;i++) {
        dp[i] = dp[i - 1];
        cnt[i] = cnt[i - 1];
        if (qs[i] + mx.first - mid > dp[i]) {
            dp[i] = qs[i] + mx.first - mid;
            cnt[i] = mx.second + 1;
        }
        mx = max(mx, { dp[i] - qs[i], cnt[i] });
    }
}
int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int k;
    cin >> n >> k;
    for (int i = 1;i <= n;i++) {
        cin >> a[i];
        qs[i] = qs[i - 1] + a[i];
    }
    ll l = 0, r = 1e13;
    while (l < r) {
        ll mid = l + (r - l) / 2;
        cal(mid);
        if (cnt[n] <= k) r = mid;
        else l = mid + 1;
    }
    cal(l);
    cout << dp[n] + l * k;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 9556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 8284 KB Output is correct
2 Correct 53 ms 8488 KB Output is correct
3 Correct 44 ms 8280 KB Output is correct
4 Incorrect 49 ms 8540 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 9808 KB Output is correct
2 Correct 70 ms 9804 KB Output is correct
3 Correct 72 ms 9868 KB Output is correct
4 Correct 73 ms 9944 KB Output is correct
5 Correct 88 ms 9888 KB Output is correct
6 Correct 70 ms 9936 KB Output is correct
7 Correct 79 ms 9812 KB Output is correct
8 Correct 68 ms 9808 KB Output is correct
9 Correct 70 ms 9808 KB Output is correct
10 Correct 101 ms 10032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2400 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2404 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2400 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2404 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2408 KB Output is correct
11 Correct 1 ms 2528 KB Output is correct
12 Correct 1 ms 2408 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2520 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2400 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2404 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2408 KB Output is correct
11 Correct 1 ms 2528 KB Output is correct
12 Correct 1 ms 2408 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2520 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2408 KB Output is correct
25 Correct 1 ms 2408 KB Output is correct
26 Correct 2 ms 2408 KB Output is correct
27 Correct 1 ms 2540 KB Output is correct
28 Correct 1 ms 2400 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 9556 KB Output isn't correct
2 Halted 0 ms 0 KB -