제출 #620035

#제출 시각아이디문제언어결과실행 시간메모리
620035gonzakia29Financial 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 solve(int)':
Main.cpp:20:27: error: 'D' was not declared in this scope
   20 |    for(int j=i+1; j-last<=D && j<=n; ++j) {
      |                           ^
Main.cpp: In function 'int main()':
Main.cpp:33:10: error: 'D' was not declared in this scope
   33 |  cin>>n>>D;
      |          ^
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;