제출 #1091265

#제출 시각아이디문제언어결과실행 시간메모리
1091265diponkinuKnapsack (NOI18_knapsack)C++14
37 / 100
1066 ms444 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int mod = 1e9+7; const int MAXN1 = 2e5 + 5; const int MAXN2 = 1e6 + 5; const int MAXN3 = 1e3 + 5; void add_self(int &x, int y){ x = x+ y; // return x; } int dp[2005], check[2005]; signed main () { int s,n ; cin >> s >> n; dp[0] = 0; for(int i = 0; i < n; i++){ int a,b,c; cin >> a >> b >> c; while(c--){ for(int j = 2000; j >= 0; j--){ if(j + b > 2000 )continue; dp[j+b] = max(dp[j+b], dp[j] + a); } } } int ans = 0; for(int i = 0; i <= s; i++){ // cout << dp[i] << "\n"; ans = max(ans, dp[i]); } cout <<ans; }
#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...