博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
The Highest Mark(01背包)
阅读量:5167 次
发布时间:2019-06-13

本文共 3207 字,大约阅读时间需要 10 分钟。

The Highest Mark

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)

Total Submission(s): 247    Accepted Submission(s): 101

Problem Description
The SDOI in 
2045 is far from what it was been 30 years ago. Each competition has t minutes and n problems.
The ith problem with the original mark of Ai(Ai106),and it decreases Bi by each minute. It is guaranteed that it does not go to minus when the competition ends. For example someone solves the ith problem after x minutes of the competition beginning. He/She will get AiBix marks.
If someone solves a problem on x minute. He/She will begin to solve the next problem on x+1 minute.
dxy who attend this competition with excellent strength, can measure the time of solving each problem exactly.He will spend Ci(Cit) minutes to solve the ith problem. It is because he is so godlike that he can solve every problem of this competition. But to the limitation of time, it's probable he cannot solve every problem in this competition. He wanted to arrange the order of solving problems to get the highest mark in this competition.
 

 

Input
There is an positive integer 
T(T10) in the first line for the number of testcases.(the number of testcases with n>200 is no more than 5)
For each testcase, there are two integers in the first line n(1n1000) and t(1t3000) for the number of problems and the time limitation of this competition.
There are n lines followed and three positive integers each line Ai,Bi,Ci. For the original mark,the mark decreasing per minute and the time dxy of solving this problem will spend.
Hint:
First to solve problem 2 and then solve problem 1 he will get 88 marks. Higher than any other order.
 

 

Output
For each testcase output a line for an integer, for the highest mark dxy will get in this competition.
 

 

Sample Input
1 4 10 110 5 9 30 2 1 80 4 8 50 3 2
 

 

Sample Output
88
题解:01背包问题。。。不过要预处理下,按照分数流失度从大到小排;
代码:
1 #include
2 #include
3 #include
4 #include
5 #define MIN(x,y)(x
y?x:y) 7 const int INF=0x3f3f3f3f; 8 using namespace std; 9 struct Node{10 int a,b,c;11 void in(){12 scanf("%d%d%d",&a,&b,&c);13 }14 friend bool operator <(Node a,Node b){15 return a.b*b.c>a.c*b.b;16 }17 };18 Node dt[1010];19 int bag[3010];20 int main(){21 int T,n,t;22 scanf("%d",&T);23 while(T--){24 scanf("%d%d",&n,&t);25 for(int i=0;i
=dt[i].c;j--){32 bag[j]=MAX(bag[j],bag[j-dt[i].c]+dt[i].a-j*dt[i].b);33 }34 }35 int max=0;36 for(int i=0;i<=t;i++)max=MAX(max,bag[i]);37 printf("%d\n",max);38 }39 return 0;40 }

明知道暴力肯定超时,还是写了下;

1 #include
2 #include
3 #include
4 #include
5 #define MIN(x,y)(x
y?x:y) 7 const int INF=0x3f3f3f3f; 8 using namespace std; 9 int n,t,ans;10 int vis[1010];11 struct Node{12 int a,b,c;13 };14 Node dt[1010];15 void dfs(int time,int score){16 if(time>t)return;17 ans=MAX(ans,score);18 for(int i=0;i

 

 

转载于:https://www.cnblogs.com/handsomecui/p/4868957.html

你可能感兴趣的文章
编译原理 First,Follow,select集求法
查看>>
iOS开发 runtime实现原理以及实际开发中的应用
查看>>
BZOJ2437 NOI2011兔兔与蛋蛋(二分图匹配+博弈)
查看>>
android 学习资源网址
查看>>
qt安装遇到的错误
查看>>
java:Apache Shiro 权限管理
查看>>
objective c的注释规范
查看>>
FreeNas安装配置使用
查看>>
Scrapy框架-CrawlSpider
查看>>
Django(一)框架简介
查看>>
Python操作SQLite数据库的方法详解
查看>>
实验二:编写输出"Hello World!"
查看>>
菜单和工具条(二)
查看>>
hadoop17---RPC和Socket的区别
查看>>
[BZOJ 3531] [Sdoi2014] 旅行 【离线+LCT】
查看>>
使用JMeter代理录制app测试脚本
查看>>
MVC 未启用角色管理功能
查看>>
Linq to Object实现分页获取数据
查看>>
mac常用系统命令
查看>>
第42章:MongoDB-集群--Sharding(分片)--单机的搭建
查看>>