제출 #1125640

#제출 시각아이디문제언어결과실행 시간메모리
1125640baoheyheyK개의 묶음 (IZhO14_blocks)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #define ll long long #define FOR(i, l, r) for(int i = (l), _r = r; i <= _r; ++i) #define FOD(i, l, r) for(int i = (l), _r = r; i >= _r; --i) #define pb push_back #define ALL(a) a.begin(), a.end() #define el "\n" #define bit(a, x) (a >> x & 1) #define X first #define Y second #define TIME (1.0 * clock() / CLOCKS_PER_SEC) #define cntbit(x) __builtin_popcountll(x) #define uni(a) sort(ALL(a)), a.resize(unique(ALL(a)) - a.begin()) #define sz(a) a.size() using namespace std; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vll; const int maxn = 1e5 + 5; ll dp[maxn][105]; ll n, a[maxn], k; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); // #define task "task" // if(fopen(task".inp", "r")){ // freopen(task".inp", "r", stdin); // freopen(task".out", "w", stdout); // } cin >> n >> k; FOR(i, 1, n) cin >> a[i]; memset(dp, 0x3f, sizeof(dp)); dp[0][1] = 0; FOR(i, 1, n) dp[i][1] = max(dp[i - 1][1], a[i]); FOR(i, 2, k){ stack<pll> st; FOR(j, i, n){ int minn = dp[j - 1][i - 1]; while(sz(st) && a[st.top().Y] <= a[j]){ minn = min(minn, st.top().X); st.pop(); } dp[j][i] = min(dp[(sz(st) ? st.top().Y : 0)][i], minn + a[j]); st.push({minn, j}); } } cout << dp[n][k]; cerr << "Time elapsed: " << TIME << " s" << el; }

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

blocks.cpp: In function 'int main()':
blocks.cpp:46:27: error: no matching function for call to 'min(int&, long long int&)'
   46 |                 minn = min(minn, st.top().X);
      |                        ~~~^~~~~~~~~~~~~~~~~~
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 blocks.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:
blocks.cpp:46:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   46 |                 minn = min(minn, st.top().X);
      |                        ~~~^~~~~~~~~~~~~~~~~~
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 blocks.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:
blocks.cpp:46:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   46 |                 minn = min(minn, st.top().X);
      |                        ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from blocks.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:
blocks.cpp:46:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   46 |                 minn = min(minn, st.top().X);
      |                        ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from blocks.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:
blocks.cpp:46:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   46 |                 minn = min(minn, st.top().X);
      |                        ~~~^~~~~~~~~~~~~~~~~~