ZOJ 3767 Elevator(水题)

97 篇文章 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 Aikilograms. 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<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<stdlib.h>
#include<cmath>
#include<string>
#include<algorithm>
#include<iostream>
#include<stdio.h>
using namespace std;
#define ll long long
#define maxn 100008
int main()
{
    int test,i,j,n,m,s,x;
    while(scanf("%d",&test)!=EOF)
    {
        while(test--)
        {
            s=0;
            scanf("%d%d",&n,&m);
            for(i=0;i<n;i++)
            {
                scanf("%d",&x);
                s+=x;
            }
            if(s>m)
            {
                printf("Warning\n");
            }
            else
                printf("Safe\n");
        }
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值