Submission #1301847

#TimeUsernameProblemLanguageResultExecution timeMemory
1301847nicolo_010Boxes with souvenirs (IOI15_boxes)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "boxes.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int mxN = 1e6+5;

ll delivery(int n, int k, int L, int* a) {
	ll l = L;
	vector<int> pos(n);
	for (int i=0; i<n; i++) {
		pos[i] = a[i];
	}
	ll dp[mxN];
	for (int i=0; i<n; i++) {
		dp[i] = 1e18;
	}
	for (int s=0; s<k; s++) {
		int le = pos[0];
		int r = pos[0+s];
		ll coste = min(2*min(r, l-le), l);
		dp[s] = coste;
	}
	for (int i=0; i<n; i++) {
		for (int s=1; s<=k; s++) {
			if (i+s >= n) break;
			ll le = pos[i];
			ll r = pos[i+s];
			ll coste = min(2*min(r, l-le), l);
			//cout << i << " " << s << " " << dp[i] << " " << coste << endl;
			dp[i+s] = min(dp[i+s], dp[i]+coste);
		}
		//cout << dp[i] << endl;
	}
	return dp[n-1];
}

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:22:37: error: no matching function for call to 'min(int&, ll)'
   22 |                 ll coste = min(2*min(r, l-le), l);
      |                                  ~~~^~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from boxes.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
boxes.cpp:22:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   22 |                 ll coste = min(2*min(r, l-le), l);
      |                                  ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
boxes.cpp:22:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   22 |                 ll coste = min(2*min(r, l-le), l);
      |                                  ~~~^~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
boxes.cpp:22:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   22 |                 ll coste = min(2*min(r, l-le), l);
      |                                  ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
boxes.cpp:22:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   22 |                 ll coste = min(2*min(r, l-le), l);
      |                                  ~~~^~~~~~~~~