제출 #1350223

#제출 시각아이디문제언어결과실행 시간메모리
1350223cpismayilmmdv985Knapsack (NOI18_knapsack)C++20
17 / 100
0 ms344 KiB
#ifdef LOCAL
#include ".debug.hpp"
#else
#define debug(...) 42
#endif
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

signed main() {
#ifndef VOID
   cin.tie(nullptr)->sync_with_stdio(false);
#endif

   int N, S;   cin >> S >> N;
   int64_t ans = 0;
   vector<array<int64_t, 3>> A(N);  for (auto &a : A) cin >> a[0] >> a[1] >> a[2];
   const int MXN = 1e6 + 5;
   vector<int64_t> dp(S + 1); 
   for (auto &[V, W, K] : A) {
      for (int j = S; j >= W; j--)  dp[j] = max(dp[j], dp[j - W] + V);
   }
   cout << *max_element(dp.begin(), dp.end());
   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...