답안 #595442

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
595442 2022-07-13T18:30:26 Z Belphegor Stove (JOI18_stove) C++14
컴파일 오류
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;