Submission #765871

#TimeUsernameProblemLanguageResultExecution timeMemory
765871raysh07Boxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int a[]) { long long ans = 0; int n = N; int k = K; int l = 0, r = n - 1; while((r - l + 1) >= k){ int mx = 0; for (int i = l; i < l + k; i++) mx = max(mx, a[i]); if (mx > (L - 1) / 2) break; ans += 2 * mx; l += k; } while ((r - l + 1) >= k){ int mn = 1e9; for (int i = r; i > r - k; i--) mn = min(mn, a[i]); if (mn <= (L - 1) / 2) break; ans += 2 * (L - mn); r -= k; } int old = ans; if ((r - l + 1) <= k) ans += L; else ans += 2 * L; int mx = 0; for (int i = l; i <= r; i++){ if (a[i] > (L - 1) / 2) break; mx = max(mx, a[i]); } int mn = L; for (int i = r; i >= l; i--){ if (a[i] <= (L - 1) / 2) break; mn = min(mn, a[i]); } ans = min(ans, old + 2 * mx + 2 * (L - mn)); return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:29:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   29 |     int old = ans;
      |               ^~~
boxes.cpp:47:47: error: no matching function for call to 'min(long long int&, int)'
   47 |     ans = min(ans, old + 2 * mx + 2 * (L - mn));
      |                                               ^
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:47:47: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   47 |     ans = min(ans, old + 2 * mx + 2 * (L - mn));
      |                                               ^
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:47:47: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   47 |     ans = min(ans, old + 2 * mx + 2 * (L - mn));
      |                                               ^
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:47:47: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   47 |     ans = min(ans, old + 2 * mx + 2 * (L - mn));
      |                                               ^
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:47:47: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   47 |     ans = min(ans, old + 2 * mx + 2 * (L - mn));
      |                                               ^