杭电 3177 Crixalis's Equipment
http://acm.hdu.edu.cn/showproblem.php?
pid=3177
Crixalis's Equipment
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2562 Accepted Submission(s): 1056

living habit of a scorpion like living underground and digging holes.
Someday Crixalis decides to move to another nice place and build a new house for himself (Actually it's just a new hole). As he collected a lot of equipment, he needs to dig a hole beside his new house to store them. This hole has a volume of V units, and Crixalis
has N equipment, each of them needs Ai units of space. When dragging his equipment into the hole, Crixalis finds that he needs more space to ensure everything is placed well. Actually, the ith equipment needs Bi units of space during the moving. More precisely
Crixalis can not move equipment into the hole unless there are Bi units of space left. After it moved in, the volume of the hole will decrease by Ai. Crixalis wonders if he can move all his equipment into the new hole and he turns to you for help.
equipment respectively. The next N lines contain N pairs of integers: Ai and Bi.
0<T<= 10, 0<V<10000, 0<N<1000, 0 <Ai< V, Ai <= Bi < 1000.
2 20 3
10 20
3 10
1 7 10 2
1 10
2 11
Yes
No
AC代码:
<span style="font-size:18px;">#include<iostream>
#include<cstdio>
#include<algorithm> using namespace std; struct Node
{
int a,b;
int c;
}s[1005]; bool cmp(Node a,Node b)
{
return a.c>b.c;
} int main()
{
int T,V,N,i;
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&V,&N);
for(i=0;i<N;i++)
{
scanf("%d%d",&s[i].a,&s[i].b);
s[i].c=s[i].b-s[i].a;
} sort(s,s+N,cmp); for(i=0;i<N;i++)
{
if(s[i].b>V)
{
printf("No\n");
break;
}
else
V=V-s[i].a;
}
if(i==N)
printf("Yes\n");
}
return 0;
}
</span>
杭电 3177 Crixalis's Equipment的更多相关文章
- HDU 3177 Crixalis's Equipment(贪婪)
主题链接:http://acm.hdu.edu.cn/showproblem.php? pid=3177 Problem Description Crixalis - Sand King used t ...
- HDOJ 3177 Crixalis's Equipment
Crixalis's Equipment Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- hdu 3177 Crixalis's Equipment
Crixalis's Equipment Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- Hdu 3177 Crixalis's Equipment
Crixalis's Equipment Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- acm入门 杭电1001题 有关溢出的考虑
最近在尝试做acm试题,刚刚是1001题就把我困住了,这是题目: Problem Description In this problem, your task is to calculate SUM( ...
- 杭电acm 1002 大数模板(一)
从杭电第一题开始A,发现做到1002就不会了,经过几天时间终于A出来了,顺便整理了一下关于大数的东西 其实这是刘汝佳老师在<算法竞赛 经典入门 第二版> 中所讲的模板,代码原封不动写上的, ...
- 杭电OJ——1198 Farm Irrigation (并查集)
畅通工程 Problem Description 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇.省政府"畅通工程"的目标是使全省任何两个城镇间都可 ...
- 杭电ACM分类
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...
- 高手看了,感觉惨不忍睹——关于“【ACM】杭电ACM题一直WA求高手看看代码”
按 被中科大软件学院二年级研究生 HCOONa 骂为“误人子弟”之后(见:<中科大的那位,敢更不要脸点么?> ),继续“误人子弟”. 问题: 题目:(感谢 王爱学志 网友对题目给出的翻译) ...
随机推荐
- GitHub上README.md教程
最近对它的README.md文件颇为感兴趣.便写下这贴,帮助更多的还不会编写README文件的同学们. README文件后缀名为md.md是markdown的缩写,markdown是一种编辑博客的语言 ...
- Mybaits+SpringMVC项目(含代码生成工具源码)
大家下载下来修改数据库配置应该就能运行起来,里面有一个SM的简单案例了,还有说明文件. 运行效果 工具类可以生成Springmvc+mybatis的相关类和配置文件,并具有增删查改的功能, ...
- fork/join使用示例
fork/join框架是用多线程的方式实现分治法来解决问题.fork指的是将问题不断地缩小规模,join是指根据子问题的计算结果,得出更高层次的结果. fork/join框架的使用有一定的约束条件: ...
- DevExpress GridView属性设置 z
本文主要总结控件的属性设置,附上图片,给大家一个参考.后续会给大家分享功能实现和使用的小技巧. GirdControl是数据的容器,它包含多种显示方式,GridView则是一种二维表格视图. 绑定数据 ...
- 陈发树云南白药股权败诉真相 取胜仅差三步 z
22亿元现金,三年只拿到750多万元的利息.福建富豪陈发树的云南生意可谓失望之极.在漫长的官司中,曾经有绝处逢生之机的陈发树,连告状的主体都没有找准,岂能同强大的国企扳手腕?陈发树律师团距取胜只有三步 ...
- 《Nagios系统监控实践》勘误
在翻译的过程中,虽然反反复复的检查了很多遍,但依然有所遗漏——这不,今天就收到了 @我是晓梦 的回复,指出了书中的一些错误. 从今天起,建立勘误表,记录这些错误,以便在下一次印刷时纠正,并对广大读者致 ...
- Trail: JDBC(TM) Database Access(3)
java.sql,javax.sql,javax.naming包 默认TYPE_FORWARD_ONLY:结果集只能向前滚动,只能调用next(),不能重定位游标 TYPE_SCROLL_INS ...
- 【Spark学习】Apache Spark监控与测量
Spark版本:1.1.1 本文系从官方文档翻译而来,转载请尊重译者的工作,注明以下链接: http://www.cnblogs.com/zhangningbo/p/4137952.html
- Windows Azure Platform (一) 云计算的出现
<Windows Azure Platform 系列文章目录> 最近的一年一直致力于微软云计算技术的推广和研究,对于微软的云计算平台Windows Azure Platform有一定的了解 ...
- nservicebus教程-目录
表的内容 开始 坚持NServiceBus 扩展 每天 举办 管理和监控 发布订阅 长时间运行的流程 定制 版本控制 常见问题解答 样品 开始 概述 NServiceBus一步一步向导 架构原则 事务 ...