# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
718674 |
2023-04-04T13:50:04 Z |
AndrijaM |
Stove (JOI18_stove) |
C++14 |
|
1 ms |
212 KB |
#include <bits/stdc++.h>
using namespace std;
long long n,k;
long long dp[5001];
long long x[5001];
long long f(long long idx,long long p)
{
if(idx==n+1)return 0;
if(p==0)return 2e9;
if(dp[idx]!=2e9)
{
return dp[idx];
}
long long rez=2e9;
for(long long i=idx;i<=n;i++)
{
if(p-1>=0)
{
rez=min(rez, f(i+1,p-1)+x[i]-x[idx]+1);
}
}
return dp[idx]=rez;
}
int main()
{
ios_base::sync_with_stdio(true);
cin>>n>>k;
for(long long i=1;i<=n;i++)
{
cin>>x[i];
}
for(long long i=0;i<=n;i++)
{
dp[i]=2e9;
}
cout<<f(1,k)<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |