Submission #1130671

#TimeUsernameProblemLanguageResultExecution timeMemory
1130671CrabCNHCandies (JOI18_candies)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define task "BriantheCrab" #define int long long #define pii pair <int, int> #define fi first #define se second #define szf sizeof #define sz(s) (int)((s).size()) using namespace std; template <class T> void mini (T &t, T f) {if (t > f) t = f;} template <class T> void maxi (T &t, T f) {if (t < f) t = f;} const int maxN = 1e5 + 5; const int inf = 1e9 + 7; const int mod = 1e9 + 7; int n; int a[maxN]; namespace sub1 { int dp[2001][2001]; // max val at the i-th place and choose j void sol () { for (int i = 1; i <= n; i ++) { for (int j = 0; j <= (i + 1) / 2; j ++) { if (j == 0) { dp[i][j] = max (dp[i - 1][j], 0); } else { dp[i][j] = max (dp[i - 1][j], dp[i - 2][j - 1] + a[i]); } } } for (int i = 1; i <= (n + 1) / 2; i ++) { cout << dp[n][i] << '\n'; } } } void Solve () { cin >> n; for (int i = 1; i <= n; i ++) { cin >> a[i]; } sub1 :: sol (); } signed main () { cin.tie (nullptr) -> sync_with_stdio (false); if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } int t = 1; //cin >> t; while (t --) { Solve (); } return 0; } // Belligerent :)

Compilation message (stderr)

candies.cpp: In function 'void sub1::sol()':
candies.cpp:31:36: error: no matching function for call to 'max(long long int&, int)'
   31 |                     dp[i][j] = max (dp[i - 1][j], 0);
      |                                ~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from candies.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
candies.cpp:31:36: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   31 |                     dp[i][j] = max (dp[i - 1][j], 0);
      |                                ~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from candies.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
candies.cpp:31:36: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   31 |                     dp[i][j] = max (dp[i - 1][j], 0);
      |                                ~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from candies.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
candies.cpp:31:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |                     dp[i][j] = max (dp[i - 1][j], 0);
      |                                ~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from candies.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
candies.cpp:31:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |                     dp[i][j] = max (dp[i - 1][j], 0);
      |                                ~~~~^~~~~~~~~~~~~~~~~
candies.cpp: In function 'int main()':
candies.cpp:55:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
candies.cpp:56:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~