Submission #595442

# Submission time Handle Problem Language Result Execution time Memory
595442 2022-07-13T18:30:26 Z Belphegor Stove (JOI18_stove) C++14
Compilation error
0 ms 0 KB
#include<iostream>
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);
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:19:2: error: 'memset' was not declared in this scope
   19 |  memset(dp,-1,sizeof(dp));
      |  ^~~~~~
stove.cpp:2:1: note: 'memset' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | using namespace std;