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 ...
随机推荐
- 【python】Python框架、库和软件资源大全
很多来自世界各地的程序员不求回报的写代码为别人造轮子.贡献代码.开发框架.开放源代码使得分散在世界各地的程序员们都能够贡献他们的代码与创新. Python就是这样一门受到全世界各地开源社区支持的语言. ...
- Nginx+tomcat+redis 集群session共享
插件资源下载地址:https://github.com/ran-jit/tomcat-cluster-redis-session-manager/releases/tag/2.0.2 一.前置条件 J ...
- python之解析csv
使用csv包 读取信息 csvfile = file('csv_test.csv', 'rb') reader = csv.reader(csvfile) for line in reader: pr ...
- 方便好使的java.util.Properties类
今天偶然碰到这个类,发现jdk中这些平时不大用到的类还挺好玩儿的,用起来也特别实在方便,随便写点记录下. java.util.Properties是对properties这类配置文件的映射.支持key ...
- bootstrap更新数据层
mq推送数据,表格实时更新,发现销毁表格不太合适,整体表格闪动,于是选择更新数据层. 先初始化表格,然后在推送数据的时候先循环遍历数据 例如: initDevTable(data.operatingL ...
- Mysql 查询列名
#列名 select COLUMN_NAME from information_schema.columns where TABLE_SCHEMA='yunpiaobox_db' and table_ ...
- Django+python实现网页数据的excel导出
一直都想做一个网页的excel导出功能,最近抽时间研究了下,使用urllib2与BeautifulSoup及xlwt模块实现 urllib2这个模块之前有用过,关于BeautifulSoup模块,可参 ...
- selenium+java,实现部分截图功能,-针对单个元素的截图
有时候需要元素的截图,不需要整个截图.整理一个针对元素的截图的方法. 创建一个Java类,实现截取元素的方法 package com.lozz.utils; import java.awt.Recta ...
- java高级工程师(三)
一.独白 之前也面试别人,现在轮到自己找工作,怎么说呢,每个面试官的看法不一样,面试的方式就不一样,比如我面试别人我喜欢问项目中他用到了那些,然后针对用到的技术去问一些问题,或者说对于某些场景的一些技 ...
- js中with 用法
with 语句用于设置代码在特定对象中的作用域. 它的语法: with (expression) statement例如: var sMessage = "hello"; with ...