ZOJ3767 Elevator
来源:互联网 发布:数控车用什么软件编程 编辑:程序博客网 时间:2024/06/06 01:50
How time flies! The graduation of this year is around the corner. N members of ZJU ACM/ICPC Team decided to hold a party in a restaurant. The restaurant is located in a skyscraper so they need to take an elevator to reach there.
The elevator's maximum load is M kilograms. The weight of the i-th team member is Ai kilograms. If the total weight of people in the elevator exceeds the maximum load of the elevator, the elevator will raise the alarm and will not move.
Please write a program to implement the weight detector of the elevator.
Input
There are multiple test cases. The first line of input is an integer T indicates the number of test cases. For each test case:
The first line contains two integers N (1 <= N <= 20) and M (1 <= M <= 2000). The next line contains N integers Ai (1 <= Ai <= 500).
Output
For each test case, output "Safe" if no alarm will be raised. Otherwise, output "Warning".
Sample Input
23 80050 60 709 80050 55 60 60 60 60 65 70 360
Sample Output
SafeWarning
直接把物品加起来判断和限重的大小
#include <iostream>#include <cstdio>using namespace std;int main(){ int T,n,m,sum,a; scanf("%d",&T); while(T--) { scanf("%d%d",&n,&m); int sum=0; for(int i=0;i<n;i++) scanf("%d",&a),sum+=a; if(sum<=m) printf("Safe\n"); else printf("Warning\n"); } return 0;}
- ZOJ3767:Elevator
- ZOJ3767 Elevator
- ZOJ3767-Elevator
- Elevator
- Elevator
- Elevator
- elevator
- Elevator
- Elevator
- Elevator
- Elevator
- Elevator
- elevator
- Elevator
- Elevator
- Elevator
- Elevator
- Elevator
- unit13 练习题
- 原子性操作(atomic operation)
- ThinkPHP如何引入扩展类?
- Android中ImageView控件ScaleType属性使用小结
- 流网络的切割
- ZOJ3767 Elevator
- 查看linux系统常用的命令,Linux查看系统配置常用命令
- 安装linux和配置java,tomcat
- 数据降维1--------PCA主成分分析原理和应用实现
- 使用util.concurrent并发包下的工具类,实现实时通知对方线程
- POJ
- Java编程思想-04控制执行流程
- mybatis #{…}与${…}差异小议
- 小型直播、视频聊天