제출 #1251934

#제출 시각아이디문제언어결과실행 시간메모리
1251934altern23Maja (COCI18_maja)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<ll, ll> #define fi first #define sec second #define ld long double const int MAXN = 2e5; const ll INF = 1e18; const int MOD = 998244353; const ld eps = 1e-6; ll C[105][105]; ll dp[105][105][205]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tc = 1; // cin >> tc; for(;tc--;){ ll N, M, A, B, K; cin >> N >> M >> A >> B >> K; K /= 2; for(int i = 1; i <= N; i++){ for(int j = 1; j <= M; j++){ cin >> C[i][j]; for(int k = 0; k <= N + M; k++) dp[i][j][k] = -INF; } } dp[A][B][0] = 0; for(int k = 1; k <= 10005; k++){ for(int i = 1; i <= N; i++){ for(int j = 1; j <= M; j++){ if(i > 1) dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][k - 1] + C[i][j]); if(i < N) dp[i][j][k] = max(dp[i][j][k], dp[i + 1][j][k - 1] + C[i][j]); if(j > 1) dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k - 1] + C[i][j]); if(j < M) dp[i][j][k] = max(dp[i][j][k], dp[i][j + 1][k - 1] + C[i][j]); } } } ll ans = 0; for(int i = 1; i <= N; i++){ for(int j = 1; j <= M; j++){ for(int k = 1; k <= min(K, 10005); k++){ ll res = K - k; if(i > 1) ans = max(ans, 2LL * (dp[i][j][k] + C[i][j] * (res / 2) + C[i - 1][j] * ((res + 1) / 2)) - (res % 2 ? C[i - 1][j] : C[i][j])); if(i < N) ans = max(ans, 2LL * (dp[i][j][k] + C[i][j] * (res / 2) + C[i + 1][j] * ((res + 1) / 2)) - (res % 2 ? C[i + 1][j] : C[i][j])); if(j > 1) ans = max(ans, 2LL * (dp[i][j][k] + C[i][j] * (res / 2) + C[i][j - 1] * ((res + 1) / 2)) - (res % 2 ? C[i][j - 1] : C[i][j])); if(j < M) ans = max(ans, 2LL * (dp[i][j][k] + C[i][j] * (res / 2) + C[i][j + 1] * ((res + 1) / 2)) - (res % 2 ? C[i][j + 1] : C[i][j])); } } } cout << ans << "\n"; } }

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

maja.cpp: In function 'int main()':
maja.cpp:45:56: error: no matching function for call to 'min(long long int&, int)'
   45 |                                 for(int k = 1; k <= min(K, 10005); k++){
      |                                                     ~~~^~~~~~~~~~
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 maja.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
maja.cpp:45:56: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   45 |                                 for(int k = 1; k <= min(K, 10005); k++){
      |                                                     ~~~^~~~~~~~~~
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 maja.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
maja.cpp:45:56: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   45 |                                 for(int k = 1; k <= min(K, 10005); k++){
      |                                                     ~~~^~~~~~~~~~
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 maja.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
maja.cpp:45:56: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |                                 for(int k = 1; k <= min(K, 10005); k++){
      |                                                     ~~~^~~~~~~~~~
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 maja.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
maja.cpp:45:56: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |                                 for(int k = 1; k <= min(K, 10005); k++){
      |                                                     ~~~^~~~~~~~~~