zoj-3767-Elevator
2016-04-24 20:56
344 查看
Description
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
Sample Output
一个电梯,电梯最大承重,n个人,每个人重量告诉你,然后问你超重没有
sabi题
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
2 3 800 50 60 70 9 800 50 55 60 60 60 60 65 70 360
Sample Output
Safe Warning
一个电梯,电梯最大承重,n个人,每个人重量告诉你,然后问你超重没有
sabi题
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; int main() { int t; scanf("%d",&t); while(t--) { int n,m; int a[25]; int sum=0; scanf("%d%d",&n,&m); for(int i=0;i<n;i++) { scanf("%d",&a[i]); sum+=a[i]; } if(sum>m) printf("Warning\n"); else printf("Safe\n"); } return 0; }
相关文章推荐
- 浅谈HTTP事务的一个过程
- 数据结构之二叉树
- 组内正则培训记录
- 【机房重构】——报表
- LeetCode 100. Same Tree C语言
- Gradle: SDK location not found, 问题与解决
- 创建离散任务时MRP净值的含义
- 大数加减法-java实现
- 51nod1083矩阵取数问题
- js传递参数中文乱码
- volatile
- 加密解密的一些认识
- hdoj-5595-GTW likes math
- NSURLSession的用法详解
- CodeForces 445A DZY Loves Chessboard
- API
- 深入浅出--C\C++指针的本质
- static的作用
- Java this和super的区别
- Mycat 流程图