2015暑假多校联合---CRB and His Birthday(01背…
2018-06-17 23:50:09来源:未知 阅读 ()
题目链接
http://acm.split.hdu.edu.cn/showproblem.php?pid=5410
She went to the nearest shop with M Won(currency unit).
At the shop, there are N kinds of presents.
It costs Wi Won to buy one present of i-th kind. (So it costs k × Wi Won to buy k of them.)
But as the counter of the shop is her friend, the counter will give Ai × x + Bi candies if she buys x(x>0) presents of i-th kind.
She wants to receive maximum candies. Your task is to help her.
1 ≤ T ≤ 20
1 ≤ M ≤ 2000
1 ≤ N ≤ 1000
0 ≤ Ai, Bi ≤ 2000
1 ≤ Wi ≤ 2000
The first line contains two integers M and N.
Then N lines follow, i-th line contains three space separated integers Wi, Ai and Bi.
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> #define eps 1e-8 #define maxn 105 #define inf 0x3f3f3f3f3f3f3f3f #define IN freopen("in.txt","r",stdin); using namespace std; int dp[2005]; int vis[2005][1005]; int kind[1005][3]; int main() { int T; int M,N; cin>>T; while(T--) { scanf("%d%d",&M,&N); for(int i=0;i<N;i++) scanf("%d%d%d",&kind[i][0],&kind[i][1],&kind[i][2]); memset(dp,0,sizeof(dp)); memset(vis,0,sizeof(vis)); for(int i=1;i<=M;i++) { int flag=-1; for(int j=0;j<N;j++) { if(i<kind[j][0]) continue; int s=dp[i-kind[j][0]]+kind[j][1]; if(!vis[i-kind[j][0]][j]) s+=kind[j][2]; if(dp[i]<s) { dp[i]=s; flag=j; } } if(flag>=0) { for(int j=0;j<N;j++) { vis[i][j]=vis[i-kind[flag][0]][j]; } vis[i][flag]++; } } int tmp=0; for(int i=1;i<=M;i++) tmp=max(tmp,dp[i]); printf("%d\n",tmp); } return 0; }
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- bzoj4036 [HAOI2015]按位或 2020-04-26
- Jesus Is Here[递推]2015沈阳online 2019-08-29
- [BZOJ4379][POI2015]Modernizacja autostrady 2019-08-16
- 番茄助手 最新 Visual Assist X 适应于VS2019 VS2017 VS2015 2019-08-16
- 【NOIP2015普及组】 推销员(纪中数据-标准) 2019-08-16
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash