Title Link: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5230
Surface:
Elevator Time limit: 2 Seconds Memory Limit: 65536 KB
How Time flies! The graduation of this year is around the corner. The members of the Zju ACM/ICPC Team decided to the a party a N restaurant. The restaurant is located-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 would raise the alarm and would not move.
Please write a program to implement the weight detector of the elevator.
Input
There is multiple test cases. The first line of input was an integer indicates the number of T test cases. For each test case:
The first line contains the integers N (1 <= N <=) and M (1 <= M <= 2000). The next line contains N integers Ai (1 <= Ai <= 500).
Output
For each test case, the output "Safe" if no alarm would be raised. Otherwise, Output "Warning".
Sample Input
23 80050 60 709 80050 55 60 60 60 60 65 70 360
Sample Output
Safewarning
Test instructions
Accumulate, if overweight, then output "Warning", otherwise output "Safe".
Code:
#include <iostream>using namespace Std;int main () {int t,n,m,sum,tmp;cin>>t;while (t--) {sum=0;cin>> n>>m;for (int i=0;i<n;i++) {cin>>tmp;sum+=tmp;} if (sum>m) cout<< "warning\n"; else cout<< "safe\n";} return 0;}
Elevator Time limit: 2 Seconds Memory Limit: 65536 KB
How Time flies! The graduation of this year is around the corner. The members of the Zju ACM/ICPC Team decided to the a party a N restaurant. The restaurant is located-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 would raise the alarm and would not move.
Please write a program to implement the weight detector of the elevator.
Input
There is multiple test cases. The first line of input was an integer indicates the number of T test cases. For each test case:
The first line contains the integers N (1 <= N <=) and M (1 <= M <= 2000). The next line contains N integers Ai (1 <= Ai <= 500).
Output
For each test case, the output "Safe" if no alarm would be raised. Otherwise, Output "Warning".
Sample Input
23 80050 60 709 80050 55 60 60 60 60 65 70 360
Sample Output
Safewarning
ZOJ 3767 Elevator