#pragma GCC optimize("O5,unroll-loops,inline,fast-math")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#include <bits/stdc++.h>
#define exoworldgd cin.tie(0)->sync_with_stdio(0), cout.tie(0)
#define int long long
#define pii pair<int,int>
using namespace std;
const int N=2005,M=1e9+7,inf=1e18;
int s,n,dp[N];
signed main(void) {
exoworldgd;
cin >> s >> n, memset(dp,0,sizeof dp);
vector<pii> v;
for (int i=0,x,w,k,cnt; i<n; i++) {
cin >> x >> w >> k,cnt=1;
while (k>0) v.emplace_back(w*min(cnt,k),x*min(cnt,k)), k-=min(cnt,k), cnt<<=1;
}
for (auto [l,r] : v) for (int j=s; j>=l; j--) dp[j]=max(dp[j],dp[j-l]+r);
cout << dp[s];
}
컴파일 시 표준 에러 (stderr) 메시지
In file included from /usr/include/c++/13/string:43,
from /usr/include/c++/13/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
from knapsack.cpp:3:
/usr/include/c++/13/bits/allocator.h: In destructor 'constexpr std::_Vector_base<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to 'always_inline' 'constexpr std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::pair<long long int, long long int>]': target specific option mismatch
184 | ~allocator() _GLIBCXX_NOTHROW { }
| ^
In file included from /usr/include/c++/13/vector:66,
from /usr/include/c++/13/functional:64,
from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here
133 | struct _Vector_impl
| ^~~~~~~~~~~~