Submission #902475

# Submission time Handle Problem Language Result Execution time Memory
902475 2024-01-10T13:07:41 Z thinknoexit Feast (NOI19_feast) C++17
100 / 100
122 ms 10536 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 * cnt[n];
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 53 ms 7248 KB Output is correct
2 Correct 66 ms 10064 KB Output is correct
3 Correct 55 ms 10356 KB Output is correct
4 Correct 56 ms 10136 KB Output is correct
5 Correct 55 ms 10260 KB Output is correct
6 Correct 53 ms 10112 KB Output is correct
7 Correct 56 ms 10148 KB Output is correct
8 Correct 55 ms 10060 KB Output is correct
9 Correct 55 ms 10076 KB Output is correct
10 Correct 68 ms 10236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 7260 KB Output is correct
2 Correct 64 ms 8532 KB Output is correct
3 Correct 45 ms 8276 KB Output is correct
4 Correct 47 ms 8508 KB Output is correct
5 Correct 67 ms 10008 KB Output is correct
6 Correct 45 ms 8272 KB Output is correct
7 Correct 54 ms 8508 KB Output is correct
8 Correct 59 ms 10336 KB Output is correct
9 Correct 54 ms 10052 KB Output is correct
10 Correct 53 ms 8596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 84 ms 7356 KB Output is correct
2 Correct 70 ms 10368 KB Output is correct
3 Correct 68 ms 10332 KB Output is correct
4 Correct 71 ms 10364 KB Output is correct
5 Correct 69 ms 10324 KB Output is correct
6 Correct 72 ms 10328 KB Output is correct
7 Correct 70 ms 10456 KB Output is correct
8 Correct 73 ms 10216 KB Output is correct
9 Correct 75 ms 10536 KB Output is correct
10 Correct 90 ms 10516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2516 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2516 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2404 KB Output is correct
17 Correct 1 ms 2516 KB Output is correct
18 Correct 1 ms 2516 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2516 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2404 KB Output is correct
17 Correct 1 ms 2516 KB Output is correct
18 Correct 1 ms 2516 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2400 KB Output is correct
24 Correct 2 ms 2396 KB Output is correct
25 Correct 2 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 2 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 7248 KB Output is correct
2 Correct 66 ms 10064 KB Output is correct
3 Correct 55 ms 10356 KB Output is correct
4 Correct 56 ms 10136 KB Output is correct
5 Correct 55 ms 10260 KB Output is correct
6 Correct 53 ms 10112 KB Output is correct
7 Correct 56 ms 10148 KB Output is correct
8 Correct 55 ms 10060 KB Output is correct
9 Correct 55 ms 10076 KB Output is correct
10 Correct 68 ms 10236 KB Output is correct
11 Correct 47 ms 7260 KB Output is correct
12 Correct 64 ms 8532 KB Output is correct
13 Correct 45 ms 8276 KB Output is correct
14 Correct 47 ms 8508 KB Output is correct
15 Correct 67 ms 10008 KB Output is correct
16 Correct 45 ms 8272 KB Output is correct
17 Correct 54 ms 8508 KB Output is correct
18 Correct 59 ms 10336 KB Output is correct
19 Correct 54 ms 10052 KB Output is correct
20 Correct 53 ms 8596 KB Output is correct
21 Correct 84 ms 7356 KB Output is correct
22 Correct 70 ms 10368 KB Output is correct
23 Correct 68 ms 10332 KB Output is correct
24 Correct 71 ms 10364 KB Output is correct
25 Correct 69 ms 10324 KB Output is correct
26 Correct 72 ms 10328 KB Output is correct
27 Correct 70 ms 10456 KB Output is correct
28 Correct 73 ms 10216 KB Output is correct
29 Correct 75 ms 10536 KB Output is correct
30 Correct 90 ms 10516 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2392 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2516 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2404 KB Output is correct
47 Correct 1 ms 2516 KB Output is correct
48 Correct 1 ms 2516 KB Output is correct
49 Correct 1 ms 2392 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 1 ms 2396 KB Output is correct
52 Correct 1 ms 2396 KB Output is correct
53 Correct 1 ms 2400 KB Output is correct
54 Correct 2 ms 2396 KB Output is correct
55 Correct 2 ms 2396 KB Output is correct
56 Correct 1 ms 2396 KB Output is correct
57 Correct 2 ms 2396 KB Output is correct
58 Correct 1 ms 2396 KB Output is correct
59 Correct 1 ms 2396 KB Output is correct
60 Correct 1 ms 2396 KB Output is correct
61 Correct 100 ms 10352 KB Output is correct
62 Correct 102 ms 10320 KB Output is correct
63 Correct 80 ms 10244 KB Output is correct
64 Correct 122 ms 10484 KB Output is correct
65 Correct 106 ms 10492 KB Output is correct
66 Correct 106 ms 10396 KB Output is correct
67 Correct 104 ms 10332 KB Output is correct
68 Correct 73 ms 10404 KB Output is correct
69 Correct 70 ms 10340 KB Output is correct
70 Correct 73 ms 10124 KB Output is correct