제출 #1318751

#제출 시각아이디문제언어결과실행 시간메모리
1318751vaishakhvSafety (NOI18_safety)C++20
컴파일 에러
0 ms0 KiB
// Source: https://usaco.guide/general/io #include <bits/stdc++.h> using namespace std; using ll = long long; #define eb emplace_back // faster than push_back xD // pbds UwU #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; #define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> // use pair for ms // my io library :D #define m1(x) template<class T, class... U> void x(T&& a, U&&... b) #define m2(x) (ll[]){(x forward<U>(b),0)...} m1(pr){cout << forward<T>(a); m2(cout << " " <<); cout << "\n";} m1(re){cin >> forward<T>(a); m2(cin >>);} int main() { ios::sync_with_stdio(0); cin.tie(0); ll n, h; re(n, h); vector<ll> s(n); for (ll i{}; i < n; i++) re(s[i]); ll maxl = *max_element(s.begin(), s.end()) + n * min(h, 500); vector<vector<ll>> dp(n, vector<ll>(maxl+1, 1e18)); for (ll i{}; i <= maxl; i++){ dp[0][i] = abs(s[0]-i); } for (ll i = 1; i < n; i++){ for (ll j{}; j < maxl; j++){ for (ll pj = max(0LL, j - h); pj <= min(maxl - 1, j + h); pj++) { dp[i][j] = min(dp[i][j], dp[i-1][pj]); } dp[i][j] += abs(j - s[i]); } } ll ans = 1e18; for (ll i{}; i < maxl; i++) ans = min(ans, dp[n-1][i]); pr(ans); }

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

safety.cpp: In function 'int main()':
safety.cpp:29:57: error: no matching function for call to 'min(ll&, int)'
   29 |     ll maxl = *max_element(s.begin(), s.end()) + n * min(h, 500);
      |                                                      ~~~^~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from safety.cpp:3:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
safety.cpp:29:57: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   29 |     ll maxl = *max_element(s.begin(), s.end()) + n * min(h, 500);
      |                                                      ~~~^~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
safety.cpp:29:57: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   29 |     ll maxl = *max_element(s.begin(), s.end()) + n * min(h, 500);
      |                                                      ~~~^~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
safety.cpp:29:57: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   29 |     ll maxl = *max_element(s.begin(), s.end()) + n * min(h, 500);
      |                                                      ~~~^~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
safety.cpp:29:57: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   29 |     ll maxl = *max_element(s.begin(), s.end()) + n * min(h, 500);
      |                                                      ~~~^~~~~~~~