# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
677197 |
2023-01-02T14:26:44 Z |
Sandarach151 |
Feast (NOI19_feast) |
C++17 |
|
102 ms |
262144 KB |
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, k;
cin >> n >> k;
long long int arr[n];
int prev[n];
long long int maxx[n];
long long int ans[k][n];
for(int i=0; i<n; i++){
cin >> arr[i];
}
maxx[0]=max(arr[0], (long long) 0);
ans[0][0]=maxx[0];
prev[0]=-1;
for(int i=1; i<n; i++){
maxx[i]=max(maxx[i-1]+arr[i], (long long) 0);
ans[0][i]=max(maxx[i], ans[0][i-1]);
if(maxx[i-1]+arr[i]>0){
prev[i]=prev[i-1];
}
else{
prev[i]=i-1;
}
}
for(int i=1; i<k; i++){
for(int j=0; j<n; j++){
if(prev[j]!=-1){
ans[i][j]=max(maxx[j]+ans[i-1][prev[j]], ans[i][j-1]);
}
else{
ans[i][j]=max(maxx[j], ans[i][j-1]);
}
}
}
cout << ans[k-1][n-1] << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
102 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
8316 KB |
Output is correct |
2 |
Correct |
22 ms |
8532 KB |
Output is correct |
3 |
Correct |
26 ms |
8272 KB |
Output is correct |
4 |
Runtime error |
98 ms |
262144 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
8404 KB |
Output is correct |
2 |
Correct |
35 ms |
11296 KB |
Output is correct |
3 |
Correct |
34 ms |
11324 KB |
Output is correct |
4 |
Correct |
34 ms |
11268 KB |
Output is correct |
5 |
Correct |
35 ms |
11332 KB |
Output is correct |
6 |
Correct |
40 ms |
11380 KB |
Output is correct |
7 |
Correct |
40 ms |
11404 KB |
Output is correct |
8 |
Correct |
35 ms |
11324 KB |
Output is correct |
9 |
Correct |
34 ms |
11440 KB |
Output is correct |
10 |
Correct |
37 ms |
11404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
102 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |