Submission #772110

#TimeUsernameProblemLanguageResultExecution timeMemory
772110asdf334Knapsack (NOI18_knapsack)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll dp[2005];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	for (ll& i : dp) i = -1;
	dp[0] = 0;
	ll S, N; cin >> S >> N;
	ll ans = 0;
	for (int i = 0; i < N; ++i) {
		ll v, w, k; 
		cin >> v >> w >> k;
		for (ll i = 2004; i >= 0; --i) {
			if (dp[i] >= 0) {
				for (ll c = 1; c <= min(floor((S - i) / w), k); ++c) {
					dp[c * w + i] = max(dp[c * w + i], dp[i] + c * v);
					ans = max(ans, dp[c * w + i]);
				}
			}
		}
	}
	cout << ans << '\n';
}

Compilation message (stderr)

knapsack.cpp: In function 'int main()':
knapsack.cpp:16:50: error: no matching function for call to 'min(__gnu_cxx::__enable_if<true, double>::__type, ll&)'
   16 |     for (ll c = 1; c <= min(floor((S - i) / w), k); ++c) {
      |                                                  ^
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 knapsack.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:
knapsack.cpp:16:50: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'll' {aka 'long long int'})
   16 |     for (ll c = 1; c <= min(floor((S - i) / w), k); ++c) {
      |                                                  ^
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 knapsack.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:
knapsack.cpp:16:50: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'll' {aka 'long long int'})
   16 |     for (ll c = 1; c <= min(floor((S - i) / w), k); ++c) {
      |                                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from knapsack.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:
knapsack.cpp:16:50: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   16 |     for (ll c = 1; c <= min(floor((S - i) / w), k); ++c) {
      |                                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from knapsack.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:
knapsack.cpp:16:50: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   16 |     for (ll c = 1; c <= min(floor((S - i) / w), k); ++c) {
      |                                                  ^