Submission #705336

#TimeUsernameProblemLanguageResultExecution timeMemory
705336bin9638Boxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define fs first #define sc second #define N 10000010 #define pb push_back ll sum_left[N],sum_right[N]; ll delivery(int n,int k,long long l,int a[]) { for(int i=1;i<=n;i++) if(i<=k) sum_left[i]=a[i-1]+min(a[i-1],l-a[i-1]); else sum_left[i]=sum_left[i-k]+1ll*a[i-1]+min(a[i-1],l-a[i-1]); for(int i=n;i>=1;i--) if(i+k-1>=n) sum_right[i]=l-a[i-1]+min(a[i-1],l-a[i-1]); else sum_right[i]=sum_right[i+k]+1ll*l-a[i-1]+min(a[i-1],l-a[i-1]); ll res=min(sum_left[n],sum_right[1]); for(int i=1;i<n;i++) res=min(res,sum_left[i]+sum_right[i+1]); return res; } #ifdef SKY int main() { freopen("A.inp","r",stdin); freopen("A.out","w",stdout); // ios::sync_with_stdio(0); // cin.tie(NULL); // cout.tie(NULL); int n,k,l; cin>>n>>k>>l; int a[n]; for(int i=0;i<n;i++) cin>>a[i]; cout<<delivery(n,k,l,a); return 0; } #endif // SKY

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, long long int, int*)':
boxes.cpp:17:51: error: no matching function for call to 'min(int&, long long int)'
   17 |             sum_left[i]=a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                   ^
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:1:
/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:17:51: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   17 |             sum_left[i]=a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                   ^
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:1:
/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:17:51: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   17 |             sum_left[i]=a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                   ^
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:1:
/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:17:51: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   17 |             sum_left[i]=a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                   ^
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:1:
/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:17:51: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   17 |             sum_left[i]=a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                   ^
boxes.cpp:18:78: error: no matching function for call to 'min(int&, long long int)'
   18 |                 else sum_left[i]=sum_left[i-k]+1ll*a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                                              ^
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:1:
/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:18:78: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   18 |                 else sum_left[i]=sum_left[i-k]+1ll*a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                                              ^
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:1:
/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:18:78: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   18 |                 else sum_left[i]=sum_left[i-k]+1ll*a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                                              ^
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:1:
/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:18:78: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   18 |                 else sum_left[i]=sum_left[i-k]+1ll*a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                                              ^
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:1:
/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:18:78: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   18 |                 else sum_left[i]=sum_left[i-k]+1ll*a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                                              ^
boxes.cpp:21:54: error: no matching function for call to 'min(int&, long long int)'
   21 |             sum_right[i]=l-a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                      ^
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:1:
/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:21:54: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   21 |             sum_right[i]=l-a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                      ^
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:1:
/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:21:54: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   21 |             sum_right[i]=l-a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                      ^
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:1:
/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:21:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |             sum_right[i]=l-a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                      ^
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:1:
/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:21:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |             sum_right[i]=l-a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                      ^
boxes.cpp:22:82: error: no matching function for call to 'min(int&, long long int)'
   22 |                 else sum_right[i]=sum_right[i+k]+1ll*l-a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                                                  ^
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:1:
/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:22:82: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   22 |                 else sum_right[i]=sum_right[i+k]+1ll*l-a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                                                  ^
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:1:
/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:22:82: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   22 |                 else sum_right[i]=sum_right[i+k]+1ll*l-a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                                                  ^
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:1:
/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:22:82: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   22 |                 else sum_right[i]=sum_right[i+k]+1ll*l-a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                                                  ^
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:1:
/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:22:82: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   22 |                 else sum_right[i]=sum_right[i+k]+1ll*l-a[i-1]+min(a[i-1],l-a[i-1]);
      |                                                                                  ^