제출 #620037

#제출 시각아이디문제언어결과실행 시간메모리
620037gonzakia29Financial Report (JOI21_financial)C++17
컴파일 에러
0 ms0 KiB
#include <iostream> using namespace std; int dp[300010]; int n, d; int a[300010]; int solve(int i) { if(i==n) { return 1; } int &ret = dp[i]; if(ret != -1){ return ret; } ret = 0; int last = i; for(int j=i+1; j-last<=d && j<=n; ++j) { if(a[j]<=a[i]){ last = j; } else { ret = max(ret, solve(j)); } } ret++; return ret; } int main(){ cin>>n>>d; for(int i=1; i<=n; ++i) { cin>>a[i]; } memset(dp, -1, sizeof dp); int ans = 0; for(int i=1; i<=n; ++i) { ans = max(ans, solve(i)); } cout<<ans; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:38:3: error: 'memset' was not declared in this scope
   38 |   memset(dp, -1, sizeof dp);
      |   ^~~~~~
Main.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;