ZOJ3767 Elevator 2017-04-13 23:32 37人阅读 评论(0) 收藏
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) 收藏的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 记一个神奇的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 ...
- *** glibc detected *** malloc(): memory corruption 分类: C/C++ Linux 2015-05-14 09:22 37人阅读 评论(0) 收藏
*** glibc detected *** malloc(): memory corruption: 0x09eab988 *** 发现是由于memset越界写引起的. 在Linux Server上 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- Vue 基本用法
Vue的基本用法 模板语法{{ }} 关闭掉 django中提供的模板语法{{ }} 指令系统 v-text v-html v-show和v-if v-bind和v-on v-for v-model ...
- java之序列化与反序列化
1.这里主要是介绍Protobuf提供的序列化与反序列化的高效性.相对于传统的java提供的序列化来说,Protobuf的效率提高了很多倍.但是也有不足的地方,就是proto在对象序列化的时候抛弃了很 ...
- nodejs连接mongodb
一.安装 a.访问mongodb官网下载https://www.mongodb.com/,有zip或者msi版本,zip解压缩就可以用,msi需要安装后使用 b.安装,指定好安装路径,一路下一步 c. ...
- blktrace btt结果分析
对于btt的结果分析十分的困难,我和同事花了很多的时间在网上查找btt输出的每一项参数的意义,试图更好的分析bio的统计信息,但网上文章一大抄,翻来覆去就是那几篇文章. 本文中内容参考了以下网址: 1 ...
- django-上下文渲染器,将后端内容提供给模板使用,自定义渲染器
使用场景:当同一个类容需要出现在多个模板中, 上下文管理器就是将这个内容以字典的形式返回给所有模板,模板通过 {{ key }}取值. 结构:上下文管理器 文件名一般为context_processo ...
- Pthreads 读写锁
▶ 使用读写锁来限制同一数据多线程读写.若任何线程拥有读锁,则其他任何请求写锁的线程将阻塞在其写锁函数的调用上:若任何线程拥有写锁,则其他任何请求读锁和写锁的线程将阻塞在其对应的锁函数上,相当于将读与 ...
- android 学习 之 布局(下)LinearLayout,RelativeLayout,TableLayout,FrameLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=&q ...
- tensorflow 卷积神经网络基本参数()
目录: 1. tf.placeholder_with_default(tf.constant(1.0),shape=[],name='use_dropout') # 设置一个占位符 2. tf.c ...
- windows删除服务的命令行语句
想要删除windows xp里的一个服务,怎么办呢? 系统没有可视化的工具可以用,不过内置了一个cmd命令 sc.exe 具体操作方法是:开始--运行--cmd,进入cmd命令行. 然后输入: sc ...
- UNITY polygon collider不随物体旋转
U3D中的一般包围框如 boxcollider, meshcollider, capsule collider等都会随物体旋转而旋转.然而polygon collider却不会. 补充:原来所有2D包 ...