# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
572187 |
2022-06-03T23:40:17 Z |
MODDI |
Feast (NOI19_feast) |
C++14 |
|
116 ms |
262144 KB |
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
int n, k;
vi arr;
ll dp[10000][2500][2];
ll f(int at, int segments, int taken){
if(at >= n)
return 0;
if(dp[at][segments][taken] != -1)
return dp[at][segments][taken];
ll best = 0;
best = max(best, arr[at] + f(at + 1, segments, 1));
if(taken == 0)
best = max(best, f(at + 1, segments, 0));
if(segments + 1 < k && taken == 1)
best = max(best, f(at + 1, segments + 1, 0));
return dp[at][segments][taken] = best;
}
int main(){
cin>>n>>k;
for(int i = 0; i < n; i++){
int a;
cin>>a;
arr.pb(a);
}
if(n > 2500 || k > 2500)
{
cout<<-1<<endl;
return 0;
}
memset(dp, -1, sizeof(dp));
cout<<f(0, 0,0)<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
105 ms |
5048 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
58 ms |
3600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
116 ms |
5376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
97 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
97 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
97 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
105 ms |
5048 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |