제출 #908632

#제출 시각아이디문제언어결과실행 시간메모리
908632Trisanu_DasFinancial Report (JOI21_financial)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int n, d, a[300005], memo[300005]; int dp(int i){ if(i == n) return 1; if(memo[i] != -1) return memo[i]; memo[i] = 0; int l = i; for(int j = i + 1; j - l <= d && j <= n; j++){ if(a[j] <= a[i]) l = j; else memo = max(memo, dp(j)); } memo[i]++; return memo[i]; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> d; for(int i = 1; i <= n; i++) cin >> a[i]; memset(memo, -1, sizeof(memo)); int ans = 0; for(int i = 0; i <= n; i++) ans = max(ans, dp(i)); cout << ans << '\n'; }

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

Main.cpp: In function 'int dp(int)':
Main.cpp:12:32: error: no matching function for call to 'max(int [300005], int)'
   12 |     else memo = max(memo, dp(j));
      |                                ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
Main.cpp:12:32: note:   deduced conflicting types for parameter 'const _Tp' ('int [300005]' and 'int')
   12 |     else memo = max(memo, dp(j));
      |                                ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
Main.cpp:12:32: note:   deduced conflicting types for parameter 'const _Tp' ('int [300005]' and 'int')
   12 |     else memo = max(memo, dp(j));
      |                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
Main.cpp:12:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int*'
   12 |     else memo = max(memo, dp(j));
      |                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
Main.cpp:12:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int*'
   12 |     else memo = max(memo, dp(j));
      |                                ^