博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 3039 Go Home
阅读量:4701 次
发布时间:2019-06-09

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

今天本来解决的很好,本来可以不聊那么结束,但是我想更完美一点,多聊几句,谁知道就聊了很长时间,很傻逼。耽误了时间!

/*************************************************************************************************/

Go Home

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 400    Accepted Submission(s): 169
Problem Description
There comes the holiday, Partychen set foot on the way home. He takes some ECNU coins to hire bodyguards to prevent from being robbed before he went home. But the bodyguard takes one coin for every kilometer. If Partychen walks without bodyguard , he will be robbed one ECNU coin by every robber on every kilometer . Of course , he can choose where to hire bodyguard or where to be robbed as he like.
For example , there are two roads on his way home and he wants to use 8 ECNU coins to hire bodyguard , the first road takes 4 kilometers with 5 robbers ( per kilometer ) and the second takes 5 kilometers with 6 robbers. He could choose the last 3 kilometers on the first road and the whole kilometers on the second road to hire bodyguard to protect him, and leave the first kilometer on the first road to be robbed by 5 robbers, which he will be robbed 5 ECNU coins.
Now , Partychen want to know how many ECNU coins will be robbed at least.
 

 

Input
It consists of multi-case .
Every case starts with two integers N and M ( 0≦N≦10,000, 0≦M≦1,000,000,000 ) which means that there are N roads and M ECNU coins to hire bodyguard.
The followed N lines contains two integers D and P (1<=D<=10,000 , 0<=P<=10 ) , which means the length of every road and the number of robbers in every kilometer on this road.
End with N=0 and M=0 .
 

 

Output
An integer means the number of ECNU coins to be robbed at least.
 

 

Sample Input
2 8 4 5 5 6 3 1 5 10 5 10 5 10 0 0
 

 

Sample Output
5 140
 

 

Source
 

 

Recommend
lcy
 
贪心,暗每千米的强盗数降序排即可
#include
#include
#include
#include
#include
#include
using namespace std;#define N 12345struct node{ int a,b;}c[N];int cmp(node n1,node n2){ return n1.b > n2.b;}int main(){ int n,m; while(~scanf("%d%d",&n,&m)&&(n+m)) { int sum=0; for(int i=0;i
=c[i].a) { sum-=c[i].b*c[i].a; m-=c[i].a; } else { sum-=c[i].b*m; break; } } cout<
<

 

转载于:https://www.cnblogs.com/wmxl/p/4697131.html

你可能感兴趣的文章
codevs1018 单词接龙(DFS)
查看>>
内容分发系统MediaEW:助新闻媒体转投HTML5
查看>>
HTML5 Canvas ( 径向渐变, 升级版的星空 ) fillStyle, createRadialGradient
查看>>
Stanford Local Programming Contest 2011
查看>>
多线程中,NSOperationQueue和GCD的区别
查看>>
python生成.exe文件
查看>>
PHP面向对象(OOP)----分页类
查看>>
监听SD卡状态
查看>>
vs2017 EFCore 迁移数据库命令
查看>>
serialVersionUID的作用
查看>>
liunx trac 插件使用之GanttCalendarPlugin
查看>>
(14)嵌入式软件开发工程师技能要求总结
查看>>
[hackerrank]Closest Number
查看>>
volatile关键字
查看>>
[Android] TabLayout设置下划线(Indicator)宽度
查看>>
<潭州教育>-Python学习笔记@条件与循环
查看>>
web自动化之验证码识别解决方案
查看>>
netty接收大文件的方法
查看>>
软件工程设计之四则运算
查看>>
SpringMVC @ResponseBody 406
查看>>