ZOJ 3767 Elevator
来源:互联网 发布:rpg游戏源码 编辑:程序博客网 时间:2024/06/03 18:13
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.
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).
<h4< dd="">For each test case, output "Safe" if no alarm will be raised. Otherwise, output "Warning".
<h4< dd="">23 80050 60 709 80050 55 60 60 60 60 65 70 360<h4< dd="">
SafeWarning
【题解】
大水题。。。
【AC代码】
#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>#include<cmath>using namespace std;const int N = 100;int main(){ int a; int t,m,n; scanf("%d",&t); while(t--) { int ans=0; scanf("%d%d",&m,&n); for(int i=0;i<m;++i) { scanf("%d",&a); ans+=a; } if(ans<=n) printf("Safe\n"); else printf("Warning\n"); } return 0;}