Submission #847738

#TimeUsernameProblemLanguageResultExecution timeMemory
847738dubabubaKnapsack (NOI18_knapsack)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int mxn = 1e6 + 10; const int mxs = 2000 + 9; int dp[mxn][mxs], n, s, ans; int pr[mxn], we[mxn], am[mxn]; signed main() { cin.tie(0)->sync_with_stdio(0); cin >> s >> n; for(int i = 1; i <= n; i++) cin >> pr[i] >> we[i] >> am[i]; for(int i = 1; i <= n; i++) for(int j = 0; j <= s; j++) { for(int k = 0; k <= am[i] && k * we[i] <= j; k++) dp[i][j] = max(dp[i][j], dp[i-1][j - we[i] * k] + pr[i] * k); ans = max(ans, dp[i][j]); } cout << ans << '\n'; return 0; }

Compilation message (stderr)

/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status