杭电 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 骂为“误人子弟”之后(见:<中科大的那位,敢更不要脸点么?> ),继续“误人子弟”. 问题: 题目:(感谢 王爱学志 网友对题目给出的翻译) ...
随机推荐
- OracleHelper(for produce)
OracleHelper中,有一个用存储过程实现的Insert方法. 然后我把执行存储过程的方法 封装成了可以执行任何存储过程,参数是 存储过程名称 以及存错过程中的传入.传出参数 using Ora ...
- Filezilla 多目录的访问设置
[转:http://hi.baidu.com/yangjie312/blog/item/125a8405423d896d03088171.html] 设置好主目录之后,点击“Add”按钮可以把其余的目 ...
- HDU-4035 Maze
http://acm.hdu.edu.cn/showproblem.php?pid=4035 树上的概率dp. Maze Time Limit: 2000/1000 MS (Java/Others ...
- HDU 4539 郑厂长系列故事——排兵布阵
http://acm.hdu.edu.cn/showproblem.php?pid=4539 郑厂长系列故事——排兵布阵 Time Limit: 10000/5000 MS (Java/Others) ...
- flash recovery area配置
检查数据库是否开启闪回: SQL> select flashback_on from v$database; FLASHBACK_ON ----------------------------- ...
- asmcmd报错
在进入asm的命令行时报错: 报错内容如下 [oracle@kel dbs]$ asmcmd asmcmd: command disallowed by current instance type 从 ...
- UNIX系统文件
密码文件 密码文件又称用户数据库,一般为/etc/passwd,对应的结构为struct passwd,该文件内容大体如下: 描述 passwd字段 用户名 char* pw_name 加密密码 ch ...
- ASP.NET MVC3 系列教程 - Razor视图引擎基础语法
http://www.cnblogs.com/highend/archive/2011/04/09/aspnet_mvc3_razor_engine.html 4. 关于所有带"_" ...
- 题目1433:FatMouse (未解决)
题目描述: FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse co ...
- leetcode—Swap Nodes in Pairs
1.题目描述 Given a linked list, swap every two adjacent nodes and return its head. For example, Given ...