제출 #891858

#제출 시각아이디문제언어결과실행 시간메모리
891858serifefedartar여행하는 상인 (APIO17_merchant)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0);cin.tie(0); typedef long long ll; #define f first #define s second #define MOD 998244353 #define LOGN 21 #define MAXN 105 #define int long long int temp[MAXN][MAXN], dist[MAXN][MAXN], sell[MAXN][MAXN]; int N, market[MAXN][1005][2]; bool check(int K) { for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) temp[i][j] = - sell[i][j] + K * min(dist[i][j], 1e18 / K); } for (int k = 1; k <= N; k++) { for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) temp[i][j] = min(temp[i][j], temp[i][k] + temp[k][j]); } } for (int i = 1; i <= N; i++) { if (temp[i][i] <= 0) return true; } return false; } signed main() { fast int M, K; cin >> N >> M >> K; for (int i = 0; i < MAXN; i++) { for (int j = 0; j < MAXN; j++) dist[i][j] = 1e18; } for (int i = 1; i <= N; i++) { for (int j = 1; j <= K; j++) cin >> market[i][j][0] >> market[i][j][1]; } for (int i = 0; i < M; i++) { int from, to, T; cin >> from >> to >> T; dist[from][to] = min(dist[from][to], T); } for (int k = 1; k < MAXN; k++) { for (int i = 1; i < MAXN; i++) { for (int j = 1; j < MAXN; j++) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); } } for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { for (int k = 1; k <= K; k++) { if (market[j][k][1] != -1 && market[i][k][0] != -1) sell[i][j] = max(sell[i][j], market[j][k][1] - market[i][k][0]); } } } int L = 1; int R = 1e10; int ans = -1; while (R >= L) { int mid = L + (R-L) / 2; if (check(mid)) { ans = mid; L = mid + 1; } else R = mid - 1; } cout << ans << "\n"; }

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

merchant.cpp: In function 'bool check(long long int)':
merchant.cpp:18:69: error: no matching function for call to 'min(long long int&, double)'
   18 |             temp[i][j] = - sell[i][j] + K * min(dist[i][j], 1e18 / K);
      |                                                                     ^
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 merchant.cpp:1:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
merchant.cpp:18:69: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double')
   18 |             temp[i][j] = - sell[i][j] + K * min(dist[i][j], 1e18 / K);
      |                                                                     ^
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 merchant.cpp:1:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
merchant.cpp:18:69: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double')
   18 |             temp[i][j] = - sell[i][j] + K * min(dist[i][j], 1e18 / K);
      |                                                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from merchant.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
merchant.cpp:18:69: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |             temp[i][j] = - sell[i][j] + K * min(dist[i][j], 1e18 / K);
      |                                                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from merchant.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
merchant.cpp:18:69: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |             temp[i][j] = - sell[i][j] + K * min(dist[i][j], 1e18 / K);
      |                                                                     ^