2014 Multi-University Training Contest 1 — D. Task

简介:

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4864


题目大意:

有N个机器。M个任务。

当中每一个机器有xi,yi。(xi表示每台机器的最长工作时间。yi表示机器能够完毕的任务难度值)

每一个任务有xi,yi。(xi表示完毕该任务须要的时间,yi表示任务的难度)每完毕一个任务,能够得到一笔钱:500 * xi + 2 * yi。

一台机器最多仅仅能做一个任务。一个任务最多仅仅能被完毕一次。

问:最多能完毕几个任务,且在完毕任务最多的情况下,能得到钱数最多为多少。


解题思路:

贪心的想法。将机器和任务依照一下规则排序:

假设xi不同。依照xi的大小从大到小排序;

假设xi同样,yi不同。依照yi的大小从大到小排序;

假设上述均同样,则依照机器排在任务前面。

经过排序之后。就保证了前面的 x 值一定比后面的 x 值大,仅仅须要比較 y 值就可以。遍历一次,假设碰到机器,则将 y 值存进一个multiset里面。假设碰到任务。那么在multiset里面找一个最小的不小于 yi 的值。用该机器去完毕该任务。


代码:

 

}






本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5141114.html,如需转载请自行联系原作者

相关文章
|
自然语言处理 算法 数据可视化
Re21:读论文 MSJudge Legal Judgment Prediction with Multi-Stage Case Representation Learning in the Real
Re21:读论文 MSJudge Legal Judgment Prediction with Multi-Stage Case Representation Learning in the Real
Re21:读论文 MSJudge Legal Judgment Prediction with Multi-Stage Case Representation Learning in the Real
|
Java
HDU - 2018 Multi-University Training Contest 3 - 1012: Visual Cube
HDU - 2018 Multi-University Training Contest 3 - 1012: Visual Cube
128 0
HDU - 2018 Multi-University Training Contest 3 - 1012: Visual Cube
|
Java
HDU - 2018 Multi-University Training Contest 1 - 1001: Maximum Multiple
HDU - 2018 Multi-University Training Contest 1 - 1001: Maximum Multiple
97 0
|
Java
HDU - 2018 Multi-University Training Contest 2 - 1010: Swaps and Inversions
HDU - 2018 Multi-University Training Contest 2 - 1010: Swaps and Inversions
107 0
|
Java
HDU - 2018 Multi-University Training Contest 2 - 1004: Game
HDU - 2018 Multi-University Training Contest 2 - 1004: Game
101 0
|
语音技术 机器学习/深度学习 开发者
语音顶会Interspeech 论文解读|Towards A Fault-tolerant Speaker Verification System: A Regularization Approach To Reduce The Condition Number
Interspeech是世界上规模最大,最全面的顶级语音领域会议,本文为Siqi Zheng, Gang Liu, Hongbin Suo, Yun Lei的入选论文
语音顶会Interspeech 论文解读|Towards A Fault-tolerant Speaker Verification System: A Regularization Approach To Reduce The Condition Number
|
Java
2017 Multi-University Training Contest - Team 9 1005&&HDU 6165 FFF at Valentine【强联通缩点+拓扑排序】
FFF at Valentine Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1060    Accepted Submission(...
1206 0
|
Java
2017 Multi-University Training Contest - Team 9 1003&&HDU 6163 CSGO【计算几何】
CSGO Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 127    Accepted Submission(s): 20 Pro...
1411 0
2015 Multi-University Training Contest 5 1009 MZL's Border
MZL's Border  Problem's Link:  http://acm.hdu.edu.cn/showproblem.php?pid=5351   Mean:  给出一个类似斐波那契数列的字符串序列,要你求给出的f[n]字符串中截取前m位的字符串s中s[1...i] = s[s.size()-i+1....s.size()]的最大长度。
926 0