제출 #1165450

#제출 시각아이디문제언어결과실행 시간메모리
1165450enzyKnapsack (NOI18_knapsack)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int maxs=2e3+10; const int maxn=1e5+10; int dp[maxs][2], v[maxn], w[maxn], k[maxn]; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int s, n; cin >> s >> n; for(int i=1;i<=n;i++){ cin >> v[i] >> w[i] >> k[i]; for(int q=1;q<=k[i];q++){ if(q*w[i]>s) break; for(int at=s;at>=q*w[i];at--) dp[at][(i%2)]=max({dp[at][(i%2)],dp[at][((i+1)%2)],dp[at-q*w[i]][((i+1)%2)]+q*v[i]}); } } int resp=0; for(int i=0;i<=s;i++) resp=max(resp,dp[i][0],dp[i][1]); cout << resp << endl; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from knapsack.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]':
knapsack.cpp:19:35:   required from here
/usr/include/c++/11/bits/stl_algobase.h:303:17: error: '__comp' cannot be used as a function
  303 |       if (__comp(__a, __b))
      |           ~~~~~~^~~~~~~~~~