Submission #1308269

#TimeUsernameProblemLanguageResultExecution timeMemory
1308269tolgaKnapsack (NOI18_knapsack)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl '\n' int main() { ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); int s, n; cin >> s >> n; vector<int> p(n), w(n), cnt(n); for (int i = 0; i < n; i++) cin >> p[i] >> w[i] >> cnt[i]; vector<ll> dp(s + 1); ll ans = 0; for (int i = 0; i < n; i++) { int K = cnt[i], get = 1; while (K) { int br = min(get, K); K -= br, get <<= 1; ll weight = br * w[i], price = br * p[i]; for (int j = s; j >= weight; j--) { if (dp[j] < dp[j - weight] + price) { dp[j] = dp[j - weight] + price; ans = max(ans, dp[j]); } } } cout << ans << endl; }

Compilation message (stderr)

knapsack.cpp: In function 'int main()':
knapsack.cpp:34:4: error: expected '}' at end of input
   34 |   }
      |    ^
knapsack.cpp:6:12: note: to match this '{'
    6 | int main() {
      |            ^