# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1092681 |
2024-09-24T18:14:33 Z |
muhammad |
Feast (NOI19_feast) |
C++17 |
|
1000 ms |
262144 KB |
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
vector<int> A(N + 1);
for (int i = 1; i <= N; ++i) {
cin >> A[i];
}
// DP array initialized with a very small value (negative infinity)
vector<vector<long long>> dp(N + 1, vector<long long>(K + 1, LLONG_MIN));
dp[0][0] = 0; // Base case
// Iterate over each possible plate
for (int i = 1; i <= N; ++i) {
for (int j = 0; j <= K; ++j) {
// If not taking the i-th plate for the j-th person
dp[i][j] = max(dp[i][j], dp[i - 1][j]);
}
// Iterate over the number of people (from 1 to K)
for (int j = 1; j <= K; ++j) {
// Keep track of the sum for the current segment ending at `i`
long long current_sum = 0;
// Iterate back from `i` to track the best sum ending at `i` for person `j`
for (int x = i; x > 0; --x) {
current_sum += A[x];
dp[i][j] = max(dp[i][j], dp[x - 1][j - 1] + current_sum);
}
}
}
cout << dp[N][K] << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
166 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1022 ms |
18516 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1047 ms |
20788 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
166 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |