Submission #1016246

#TimeUsernameProblemLanguageResultExecution timeMemory
1016246onbertBoxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define int long long const int maxn = 1e7 + 5; int n, k, l; int a[maxn]; vector<int> solve() { int cnt[k]; for (int i=0;i<k;i++) cnt[i] = 0; vector<int> cost(n); for (int i=0;i<n;i++) { cnt[i%k] += a[i] * 2; cost[i] = cnt[i%k]; } return cost; } long long delivery(int32_t N, int32_t K, int32_t L, int32_t p[]) { k = K, l = L; n = 0; for (int i=0;i<N;i++) { if (p[i]!=0) a[n] = p[i], n++; } if (n==0) return (int)0; sort(a, a+n); int ans = min({a[n-1]*2, (L-a[0])*2, L}); for (int i=0;i<n-1;i++) ans = min(a[i]*2 + (L-a[i+1])*2, ans); return ans; // vector<int> fwd = solve(); // for (int i=0;i<n;i++) a[i] = L - a[i]; // reverse(a, a+n); // // for (int i=0;i<n;i++) cout << a[i] << " "; cout << endl; // vector<int> bwd = solve(); // reverse(bwd.begin(), bwd.end()); // // for (int i=0;i<n;i++) cout << fwd[i] << " "; cout << endl; // // for (int i=0;i<n;i++) cout << bwd[i] << " "; cout << endl; // int ans = min(fwd[n-1], bwd[0]); // for (int i=0;i<n-1;i++) ans = min(fwd[i] + bwd[i+1], ans); // // cout << ans << endl; // return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int32_t, int32_t, int32_t, int32_t*)':
boxes.cpp:29:44: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   29 |     int ans = min({a[n-1]*2, (L-a[0])*2, L});
      |                                            ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from boxes.cpp:2:
/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:
boxes.cpp:29:44: note:   candidate expects 2 arguments, 1 provided
   29 |     int ans = min({a[n-1]*2, (L-a[0])*2, L});
      |                                            ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from boxes.cpp:2:
/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:
boxes.cpp:29:44: note:   candidate expects 3 arguments, 1 provided
   29 |     int ans = min({a[n-1]*2, (L-a[0])*2, L});
      |                                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:2:
/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:
boxes.cpp:29:44: note:   deduced conflicting types for parameter '_Tp' ('long long int' and 'int')
   29 |     int ans = min({a[n-1]*2, (L-a[0])*2, L});
      |                                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:2:
/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:
boxes.cpp:29:44: note:   deduced conflicting types for parameter '_Tp' ('long long int' and 'int')
   29 |     int ans = min({a[n-1]*2, (L-a[0])*2, L});
      |                                            ^