ZOJ 3767 Elevator

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.