HDU 3039 Go Home
今天本来解决的很好,本来可以不聊那么结束,但是我想更完美一点,多聊几句,谁知道就聊了很长时间,很傻逼。耽误了时间!
/*************************************************************************************************/
Go Home
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 400 Accepted Submission(s): 169
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.
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 .
4 5
5 6
3 1
5 10
5 10
5 10
0 0
140
#include<queue>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define N 12345
struct 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=;
for(int i=;i<n;i++)
{
scanf("%d%d",&c[i].a,&c[i].b);
sum+=c[i].a*c[i].b;
}
sort(c,c+n,cmp);
for(int i=;i<n;i++)
{
if(m>=c[i].a)
{
sum-=c[i].b*c[i].a;
m-=c[i].a;
}
else
{
sum-=c[i].b*m;
break;
}
}
cout<<sum<<endl;
}
return ;
}
HDU 3039 Go Home的更多相关文章
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- hdu 4481 Time travel(高斯求期望)(转)
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...
- HDU 3791二叉搜索树解题(解题报告)
1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/articl ...
- hdu 4329
problem:http://acm.hdu.edu.cn/showproblem.php?pid=4329 题意:模拟 a. p(r)= R'/i rel(r)=(1||0) R ...
随机推荐
- bash文件名统配
bash基础特性之globbing,即文件名通配: 文件名通配:使用元字符匹配字符 *:匹配任意长度的任意字符 假如文件名为paaaa,则pa*,*pa ...
- vscode and python
http://robotkang.cc/2017/04/VS-Code-%E9%85%8D%E7%BD%AEPython/
- OmniGraffler软件和激活码
mac上用户画图的软件:OmniGraffler破解方法 1.激活码 Name: Appked SN: MFWG-GHEB-HYTW-CGHT-CSXU-QCNC-SXU 2.软件连接 链接: htt ...
- 九度oj 题目1139:最大子矩阵
题目描述: 已知矩阵的大小定义为矩阵中所有元素的和.给定一个矩阵,你的任务是找到最大的非空(大小至少是1 * 1)子矩阵. 比如,如下4 * 4的矩阵 0 -2 -7 0 9 2 -6 2 -4 1 ...
- hdu 1390
#include<stdio.h> int main() { int t,n,a[1001]; scanf("%d",&t); while(t--) { sca ...
- Spring JdbcTemplate操作小结
Spring 提供了JdbcTemplate 来封装数据库jdbc操作细节: 包括: 数据库连接[打开/关闭] ,异常转义 ,SQL执行 ,查询结果的转换 使用模板方式封装 jdbc数据库操作-固定流 ...
- docker命令解析
1.docker run --name lllllll -d -p 8080:8080 -p 9000:9000 镜像id 将docker8080端口映射到服务器的8080端口 ...
- CentOS7关于网络的设置
装好CentOS7后,我们一开始是上不了网的 这时候,可以输入命令dhclient,可以自动获取一个IP地址,再用命令ip addr查看IP 不过这时候获取的IP是动态的,下次重启系统后,IP地址也会 ...
- csv文件导出
参考博客:http://www.cnblogs.com/mingforyou/p/4103132.html 导入jar包javacsv.jar 链接:http://pan.baidu.com/s/1i ...
- Spring Task Schedule 及多线程
http://spring.io/blog/2010/01/05/task-scheduling-simplifications-in-spring-3-0/‘ http://ekramalikazi ...