Submission #218739

#TimeUsernameProblemLanguageResultExecution timeMemory
218739someone_aaK blocks (IZhO14_blocks)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair using namespace std; const int maxn = 100100; const int maxk = 110; ll n, k; ll dp[maxn][maxk]; ll arr[maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin>>n>>k; int prefmax = 0; for(int i=0;i<=n;i++) { for(int j=0;j<=k;j++) { dp[i][j] = (INT_MAX); } } for(int i=1;i<=n;i++) { cin>>arr[i]; prefmax = max(prefmax, arr[i]); dp[i][1] = prefmax; } for(int d=2;d<=k;d++) { stack<int>dps, arrs; for(int i=1;i<=n;i++) { int curr = dp[i-1][d-1]; while(!arrs.empty() && arrs.top() < arr[i]) { curr = min(curr, dps.top()); arrs.pop(); dps.pop(); } if(arrs.empty() || arrs.top() + dps.top() >= curr + arr[i]) { arrs.push(arr[i]); dps.push(curr); } if(i >= d) dp[i][d] = arrs.top() + dps.top(); } } cout<<dp[n][k]<<"\n"; }

Compilation message (stderr)

blocks.cpp: In function 'int main()':
blocks.cpp:27:32: error: no matching function for call to 'max(int&, long long int&)'
   prefmax = max(prefmax, arr[i]);
                                ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from blocks.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
blocks.cpp:27:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   prefmax = max(prefmax, arr[i]);
                                ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from blocks.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
blocks.cpp:27:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   prefmax = max(prefmax, arr[i]);
                                ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from blocks.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
blocks.cpp:27:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   prefmax = max(prefmax, arr[i]);
                                ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from blocks.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
blocks.cpp:27:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   prefmax = max(prefmax, arr[i]);
                                ^