首页 > 其他 > 详细

ZOJ3767:Elevator

时间:2014-04-07 13:53:35      阅读:487      评论:0      收藏:0      [点我收藏+]

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
 
 
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>
#include <stack>
using namespace std;

int main()
{
    int t,n,sum,maxn;
    cin >> t;
    while(t--)
    {
        sum = 0;
        cin >> n >> maxn;
        for(int i = 0;i<n;i++)
        {
            int x;
            cin >> x;
            sum+=x;
        }
        if(sum>maxn)
        printf("Warning\n");
        else
        printf("Safe\n");
    }

    return 0;
}

ZOJ3767:Elevator,布布扣,bubuko.com

ZOJ3767:Elevator

原文:http://blog.csdn.net/libin56842/article/details/23092523

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!