Elevator


Time Limit: 2 Seconds      Memory Limit: 65536 KB


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>
using namespace std; int main()
{
int T,n,m,sum,a;
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&m);
int sum=0;
for(int i=0;i<n;i++)
scanf("%d",&a),sum+=a;
if(sum<=m)
printf("Safe\n");
else
printf("Warning\n");
}
return 0;
}

ZOJ3767 Elevator 2017-04-13 23:32 37人阅读 评论(0) 收藏的更多相关文章

  1. HDU2680 Choose the best route 最短路 分类: ACM 2015-03-18 23:30 37人阅读 评论(0) 收藏

    Choose the best route Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  2. ZOJ2482 IP Address 2017-04-18 23:11 44人阅读 评论(0) 收藏

    IP Address Time Limit: 2 Seconds      Memory Limit: 65536 KB Suppose you are reading byte streams fr ...

  3. PAT甲 1008. Elevator (20) 2016-09-09 23:00 22人阅读 评论(0) 收藏

    1008. Elevator (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The highest ...

  4. hdu 1034 (preprocess optimization, property of division to avoid if, decreasing order process) 分类: hdoj 2015-06-16 13:32 39人阅读 评论(0) 收藏

    IMO, version 1 better than version 2, version 2 better than version 3. make some preprocess to make ...

  5. 记一个神奇的WAS问题:sibuswsgw-sibuswsgw_console.jar invalid LOC header (bad signature) 分类: WebSphere 2015-08-06 23:21 9人阅读 评论(0) 收藏

    今天晚上,出现了一个神奇的WAS问题,详细问题异常信息如下: [15-8-6 22:13:29:146 CST] 00000013 ApplicationMg A WSVR0203I: 应用程序:is ...

  6. *** glibc detected *** malloc(): memory corruption 分类: C/C++ Linux 2015-05-14 09:22 37人阅读 评论(0) 收藏

    *** glibc detected *** malloc(): memory corruption: 0x09eab988 *** 发现是由于memset越界写引起的. 在Linux Server上 ...

  7. NYOJ-235 zb的生日 AC 分类: NYOJ 2013-12-30 23:10 183人阅读 评论(0) 收藏

    DFS算法: #include<stdio.h> #include<math.h> void find(int k,int w); int num[23]={0}; int m ...

  8. Hdu 1009 FatMouse' Trade 2016-05-05 23:02 86人阅读 评论(0) 收藏

    FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...

  9. PAT甲 1029. Median (25) 2016-09-09 23:11 27人阅读 评论(0) 收藏

    1029. Median (25) 时间限制 1000 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given an incr ...

随机推荐

  1. 桶排序与快速排序算法结合-python实现

    #-*- coding: UTF-8 -*- import numpy as np from QuickSort import QuickSort def BucketSort(a, n): barr ...

  2. 【linux】查看linux版本和内核版本

    查看linux版本:uname -r 查看linux版本内核:lsb_release -a

  3. Android开源项目汇总

    Android很多优秀的开源项目,很多UI组件以及经典的HTTP 访问开源,都能给我们带来一些自己项目的启迪或者引用. 下面简单介绍一下自己收藏的一些项目内容. 项目: Apollo音乐播放器:And ...

  4. HDU 1717 小数化分数2(最大公约数)

    小数化分数2 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Subm ...

  5. mysql-8 alter命令

    当我们需要修改数据表名或者修改数据表字段时,就需要用到Mysql alter命令. 查看表结构: -- 以下2个命令是通用的 show columns from test_alter_tbl; des ...

  6. ExtJS组件扩展

    1.extends 2.initComponent 3.constracot: 4.onRender:重新写这个方法 ========================================= ...

  7. dd命令的conv=fsync,oflag=sync/dsync

    conv的参数有 1.sync Pad every input block to size of 'ibs' with trailing zero bytes. When used with 'blo ...

  8. delphi 组件容器TObjectList代替List

    delphi 组件容器TObjectList代替List TObjectList objList->delete(0); 这个会释放第0行元素的对象 class TTabFormInfo { p ...

  9. JS 位数不够自动左补0

    var mycode = "11"; mycode = (Array(4).join(0) + parseInt(mycode)).slice(-4);//0011 mycode1 ...

  10. Java Reference & ReferenceQueue一览

    Overview The java.lang.ref package provides more flexible types of references than are otherwise ava ...