Submission #1326042

#TimeUsernameProblemLanguageResultExecution timeMemory
1326042c0d3xx_Knapsack (NOI18_knapsack)C++20
37 / 100
1094 ms1848 KiB
#include <bits/stdc++.h>
#define maxn 2003
#define pii pair<ll, ll> 
#define tpe tuple<int, int, int>
#define MOD 1000000007
#define ll long long
#define lim 44725
#define file "mind"
#define base 131
using namespace std;

int n, c;
ll d[maxn][maxn];
int main() {
    
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> c >> n;
  for(int i = 1; i <= n; i++) {
    int w, v, k; 
    cin >> v >> w >> k;
    for(int j = 0; j <= c; j++) {
      d[i][j] = d[i-1][j];
      for(int t = 1; t <= k; t++) {
        if(j >= w * t) d[i][j] = max(d[i][j], d[i-1][j-w*t] + v * t);
      }
    }
  }
  
  cout << d[n][c];
}
#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...