Submission #595443

# Submission time Handle Problem Language Result Execution time Memory
595443 2022-07-13T18:30:45 Z Belphegor Stove (JOI18_stove) C++14
50 / 100
112 ms 98508 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int T[5005];
int dp[5005][5005];
int f(int n,int k){
	int&ret = dp[n][k];
	if(~ret) return ret;
	ret = 1e9+1;
	if(!k) return ret;
	if(!n) return ret = 1;
	ret = min(ret,f(n-1,k-1)+1);
	ret = min(ret,f(n-1,k)+T[n]-T[n-1]);
	return ret;
}
int main(){
	int n,k; cin>>n>>k;
	for(int i=0; i<n; i++) cin>>T[i];
	memset(dp,-1,sizeof(dp));
	cout<<f(n-1,k);
}
# Verdict Execution time Memory Grader output
1 Correct 36 ms 98252 KB Output is correct
2 Correct 36 ms 98304 KB Output is correct
3 Correct 36 ms 98244 KB Output is correct
4 Correct 43 ms 98252 KB Output is correct
5 Correct 38 ms 98292 KB Output is correct
6 Correct 36 ms 98252 KB Output is correct
7 Correct 36 ms 98260 KB Output is correct
8 Correct 38 ms 98320 KB Output is correct
9 Correct 37 ms 98232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 98252 KB Output is correct
2 Correct 36 ms 98304 KB Output is correct
3 Correct 36 ms 98244 KB Output is correct
4 Correct 43 ms 98252 KB Output is correct
5 Correct 38 ms 98292 KB Output is correct
6 Correct 36 ms 98252 KB Output is correct
7 Correct 36 ms 98260 KB Output is correct
8 Correct 38 ms 98320 KB Output is correct
9 Correct 37 ms 98232 KB Output is correct
10 Correct 40 ms 98380 KB Output is correct
11 Correct 44 ms 98488 KB Output is correct
12 Correct 79 ms 98508 KB Output is correct
13 Correct 100 ms 98396 KB Output is correct
14 Correct 98 ms 98468 KB Output is correct
15 Correct 112 ms 98500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 98252 KB Output is correct
2 Correct 36 ms 98304 KB Output is correct
3 Correct 36 ms 98244 KB Output is correct
4 Correct 43 ms 98252 KB Output is correct
5 Correct 38 ms 98292 KB Output is correct
6 Correct 36 ms 98252 KB Output is correct
7 Correct 36 ms 98260 KB Output is correct
8 Correct 38 ms 98320 KB Output is correct
9 Correct 37 ms 98232 KB Output is correct
10 Correct 40 ms 98380 KB Output is correct
11 Correct 44 ms 98488 KB Output is correct
12 Correct 79 ms 98508 KB Output is correct
13 Correct 100 ms 98396 KB Output is correct
14 Correct 98 ms 98468 KB Output is correct
15 Correct 112 ms 98500 KB Output is correct
16 Runtime error 4 ms 724 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -