# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1025668 |
2024-07-17T08:36:37 Z |
fv3 |
Feast (NOI19_feast) |
C++14 |
|
718 ms |
262144 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int N, K;
cin >> N >> K;
vector<ll> a(N);
for (int i = 0; i < N; i++)
cin >> a[i];
// Maximize satisfaction with 1, then 2, then ... segments
vector<vector<ll>> dp(K+1, vector<ll>(N));
vector<vector<ll>> mx(K+1, vector<ll>(N));
for (int k = 1; k <= K; k++)
{
for (int i = 0; i < N; i++)
{
dp[k][i] = max(0ll, a[i]);
if (i)
dp[k][i] = max({dp[k][i], dp[k][i-1] + a[i], mx[k-1][i-1] + a[i]});
mx[k][i] = dp[k][i];
if (i)
mx[k][i] = max(mx[k][i-1], dp[k][i]);
cerr << mx[k][i] << ' ';
}
cerr << '\n';
}
cout << dp[K][N-1] << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
153 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
670 ms |
16592 KB |
Output is correct |
2 |
Correct |
656 ms |
17172 KB |
Output is correct |
3 |
Incorrect |
659 ms |
16740 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
718 ms |
17812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
153 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |