Submission #386634

#TimeUsernameProblemLanguageResultExecution timeMemory
386634mehrdad_sohrabiBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
/// Black lives matter #include <bits/stdc++.h> #include "boxes.h" /// 500 485 462 A4 using namespace std; typedef long long int ll; typedef complex<double> point; typedef long double ld; #define pb push_back #define pii pair < ll , ll > #define F first #define S second //#define endl '\n' #define int long long #define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") #define kill(x) return cout<<x<<'\n', 0; const int MAXN=1e5+10; ll dp[MAXN],pd[MAXN]; ll t[MAXN]; long long delivery(int32_t n, int32_t k, int32_t l, int32_t p[]) { for (int i=0;i<n;i++) dp[i]=(ll)1e15,pd[i]=(ll)1e15; sort(p,p+n); ll cnt=0; dp[0]=0,pd[0]=0; for (int i=0;i<n;i++){ cnt++; dp[cnt]=2*p[i]+dp[max((ll)0,cnt-k)]; } cnt=0; for (int i=n-1;i>-1;i--){ cnt++; pd[cnt]=2*((l-p[i])%l)+pd[max((ll)0,cnt-k)]; } ll ans=(ll)1e15; if (k==n) ans=min(ans,l); for (int i=0;i<=n;i++){ ans=min(ans,dp[i]+pd[n-i]); } return ans; } /* int32_t p[MAXN]; int32_t main(){ sync; ll n,k,l; cin >> n >> k >> l; for (int i=0;i<n;i++){ cin >> p[i]; } cout << delivery(n,k,l,p); } */ /* 3 2 8 1 2 5 */

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int32_t, int32_t, int32_t, int32_t*)':
boxes.cpp:36:28: error: no matching function for call to 'min(ll&, int32_t&)'
   36 |     if (k==n) ans=min(ans,l);
      |                            ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
boxes.cpp:36:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int32_t' {aka 'int'})
   36 |     if (k==n) ans=min(ans,l);
      |                            ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
boxes.cpp:36:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int32_t' {aka 'int'})
   36 |     if (k==n) ans=min(ans,l);
      |                            ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
boxes.cpp:36:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |     if (k==n) ans=min(ans,l);
      |                            ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
boxes.cpp:36:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |     if (k==n) ans=min(ans,l);
      |                            ^