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.

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).

<h4< dd="">
Output

For each test case, output "Safe" if no alarm will be raised. Otherwise, output "Warning".

<h4< dd="">
Sample Input
23 80050 60 709 80050 55 60 60 60 60 65 70 360
<h4< dd="">
Sample Output
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;}



阅读全文
'); })();
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 多了 多晚 多. 多, 多虑 多视 重庆有多宠游客 完美多美 金多宝 完美有多美 多米头条 白带多原因 场流星雨将至 我师父很多 场多音字 皮肤多痣 太多歌词 多玩首页 太多 多玩手游 多的拼音 多玩手游网 多玩psp 多拼音 duowan 多玩 多玩网 维客多 刮大白多钱一平 洗牙多钱一次 果粒多 月经量多周期短 多点触控测试 石榴石多钱一克 多游网 痛经月经量多 断桥铝多钱一平 可聊99多人聊天室 夜尿多挂什么科 蛋痛有多痛 西洋参多钱一克