제출 #840440

#제출 시각아이디문제언어결과실행 시간메모리
840440tch1cherin여행하는 상인 (APIO17_merchant)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const long long INF = 1ll << 60; int main() { cin.tie(nullptr)->sync_with_stdio(false); int64_t N, M, K; cin >> N >> M >> K; vector<vector<int64_t>> B(N, vector<int64_t>(K)), S(N, vector<int64_t>(K)); for (int i = 0; i < N; i++) { for (int j = 0; j < K; j++) { cin >> B[i][j] >> S[i][j]; } } vector<vector<pair<int64_t, int64_t>>> G(N); for (int i = 0; i < M; i++) { int64_t u, v, t; cin >> u >> v >> t; u--, v--; G[u].push_back({v, t}); } vector dist(N, vector<long long>(N, INF)); for (int u = 0; u < N; u++) { for (auto [v, t] : G[u]) { dist[u][v] = t; } } for (int k = 0; k < N; k++) for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); vector profit(N, vector<int64_t>(N)); for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) for (int k = 0; k < K; k++) if (B[i][k] != -1 && S[j][k] != -1) profit[i][j] = max(profit[i][j], (long long)S[j][k] - B[i][k]); int64_t l = -1, r = 1 << 30; while (r > l + 1) { int64_t mid = (l + r) / 2; vector dis(N, vector<__int128_t>(N, INF)); for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) dis[i][j] = min(INF, 1LL * min(2 * INF / mid, dist[i][j]) * mid - profit[i][j]); for (int k = 0; k < N; k++) for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]); bool good = false; for (int i = 0; i < N; i++) { if (dis[i][i] <= 0) { good = true; } } if (good) { l = mid; } else { r = mid; } } cout << l << "\n"; }

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

merchant.cpp: In function 'int main()':
merchant.cpp:39:72: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&, long long int)'
   39 |           profit[i][j] = max(profit[i][j], (long long)S[j][k] - B[i][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: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:
merchant.cpp:39:72: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   39 |           profit[i][j] = max(profit[i][j], (long long)S[j][k] - B[i][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: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:
merchant.cpp:39:72: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   39 |           profit[i][j] = max(profit[i][j], (long long)S[j][k] - B[i][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: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:
merchant.cpp:39:72: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   39 |           profit[i][j] = max(profit[i][j], (long long)S[j][k] - B[i][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: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:
merchant.cpp:39:72: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   39 |           profit[i][j] = max(profit[i][j], (long long)S[j][k] - B[i][k]);
      |                                                                        ^