제출 #973803

#제출 시각아이디문제언어결과실행 시간메모리
973803pfkKnapsack (NOI18_knapsack)C++14
73 / 100
1082 ms2668 KiB
#include <iostream> #include <vector> using namespace std; //ifstream cin("input.in"); //ofstream cout("output.out"); #define mod 1000000007 struct item { long long v, w, k; }; long long dp[4005],Max; long long s, n; item a[100005]; int main() { cin >> s >> n; for (int i = 1; i <= n; i++) { cin >> a[i].v >> a[i].w >> a[i].k; a[i].k = min(a[i].k, s / a[i].w); } for (int i = 1; i <= n; i++) while (a[i].k--) for (int j = s; j >= a[i].w; j--) dp[j] = max(dp[j], dp[j - a[i].w] + a[i].v); for (int i = 1; i <= s; i++) Max = max(Max, dp[i]); cout << Max; 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...