이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, s; cin >> s >> n;
    vector < pii > val;
    for (int i = 1, v, w, k; i <= n; i++) {
        cin >> v >> w >> k;
        int total = 0;
        for (int i = 1; i <= k && total <= s; i++) {
            val.push_back({ v, w });
            total += w;
        }
    }
    vector < int > dp(s + 1, -1);
    dp[0] = 0;
    for (auto [v, w] : val)
        for (int cur = s; cur >= w; cur--)
            if (dp[cur - w] >= 0)
                dp[cur] = max(dp[cur], dp[cur - w] + v);
    cout << *max_element(dp.begin(), dp.end()) << "\n";
}
컴파일 시 표준 에러 (stderr) 메시지
knapsack.cpp: In function 'int main()':
knapsack.cpp:31:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   31 |     for (auto [v, w] : val)
      |               ^| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |