제출 #1192477

#제출 시각아이디문제언어결과실행 시간메모리
1192477dprtoKnapsack (NOI18_knapsack)C++20
17 / 100
0 ms328 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define x first
#define y second
#define MASK(i) (1 << (i))
#define BIT(x, i) (((x) >> (i)) & 1)
#define f(i, l, r) for(int i = l; i <= r; ++i)
const int mod = 1e9 + 7;
const int ars = 2e5 + 5;
const ll infll = 1e18;


int s, n, v[ars], w[ars], k[ars], dp[2005];

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s >> n;
    f(i, 1, n) cin >> v[i] >> w[i] >> k[i];
    f(i, 1, n){
        for(int j = s; j >= w[i]; --j){
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
        }
    }
    cout << dp[s];


    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...