Submission #1090710

#TimeUsernameProblemLanguageResultExecution timeMemory
1090710trandangquang날다람쥐 (JOI14_ho_t4)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5+5; using ll = long long; int n, m, x, h[N]; ll mxh[N]; vector <pair <int, int>> adj[N]; int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> m >> x; for(int i = 1; i <= n; ++i) cin >> h[i]; for(int i = 1; i <= m; ++i) { int u, v, w; cin >> u >> v >> w; if(h[u] >= w) adj[u].emplace_back(v, w); if(h[v] >= w) adj[v].emplace_back(u, w); } fill(mxh+1, mxh+1+n, -1e18); mxh[1] = x; priority_queue <pair <ll, int>> pq; pq.push({x, 1}); while(pq.size()) { pair <ll, int> tp = pq.top(); pq.pop(); ll hu = tp.first; int u = tp.second; if(hu < mxh[u]) continue; for(pair <int, int> i : adj[u]) { int v = i.first, w = i.second; ll hv = min(hu-w, h[v]); if(hv > mxh[v]) { mxh[v] = hv; pq.push({hv, v}); } } } if(mxh[n] == (ll)-1e18) cout << "-1\n"; else cout << x + h[n] - 2*mxh[n] << '\n'; }

Compilation message (stderr)

2014_ho_t4.cpp: In function 'int main()':
2014_ho_t4.cpp:36:35: error: no matching function for call to 'min(ll, int&)'
   36 |             ll hv = min(hu-w, h[v]);
      |                                   ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from 2014_ho_t4.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:
2014_ho_t4.cpp:36:35: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   36 |             ll hv = min(hu-w, h[v]);
      |                                   ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from 2014_ho_t4.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:
2014_ho_t4.cpp:36:35: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   36 |             ll hv = min(hu-w, h[v]);
      |                                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from 2014_ho_t4.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:
2014_ho_t4.cpp:36:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |             ll hv = min(hu-w, h[v]);
      |                                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from 2014_ho_t4.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:
2014_ho_t4.cpp:36:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |             ll hv = min(hu-w, h[v]);
      |                                   ^