标签:mis 实例 temp || 数据 inline code 未来 假设
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 40460 Accepted Submission(s): 17144
#include<bits/stdc++.h> #include<queue> #include<cstdio> #include<iostream> #define REP(i, a, b) for(int i = (a); i <= (b); ++ i) #define REP(j, a, b) for(int j = (a); j <= (b); ++ j) #define PER(i, a, b) for(int i = (a); i >= (b); -- i) using namespace std; template <class T> inline void rd(T &ret){ char c; ret = 0; while ((c = getchar()) < ‘0‘ || c > ‘9‘); while (c >= ‘0‘ && c <= ‘9‘){ ret = ret * 10 + (c - ‘0‘), c = getchar(); } } struct node{int val,w,cnt;}p[105]; int dp[110]; int main() { int T; rd(T); while(T--){ int m,n; rd(n),rd(m); memset(dp,0,sizeof(dp)); for(int i=1;i<=m;i++){ cin>>p[i].val>>p[i].w>>p[i].cnt; } for(int i=1;i<=m;i++){ for(int j=1;j<=p[i].cnt;j++){ for(int k=n;k>=p[i].val;k--){ dp[k]=max(dp[k],dp[k-p[i].val]+p[i].w); } } } cout<<dp[n]<<endl; } return 0; }
标签:mis 实例 temp || 数据 inline code 未来 假设
原文地址:https://www.cnblogs.com/czy-power/p/10372083.html