ZOJ 3767 Elevator
2015-04-10 21:36
253 查看
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5230
题面:
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.
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).
题意:
累加,若超重,则输出"Warning",否则输出"Safe"。
代码:
题面:
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
题意:
累加,若超重,则输出"Warning",否则输出"Safe"。
代码:
#include<iostream> using namespace std; int main() { int t,n,m,sum,tmp; cin>>t; while(t--) { sum=0; cin>>n>>m; for(int i=0;i<n;i++) { cin>>tmp; sum+=tmp; } if(sum>m)cout<<"Warning\n"; else cout<<"Safe\n"; } return 0; }
相关文章推荐
- zoj-3767-Elevator
- ZOJ 3767-Elevator
- ZOJ 3767 Elevator
- 第14届浙江大学程序设计竞赛 A. Elevator(ZOJ 3767)
- ZOJ 3767 Elevator(水题)
- ZOJ 3767 Elevator
- ZOJ-3767
- ZOJ 3767
- zoj 3767(浙大校赛)
- Elevator(Zoj 2108)
- zoj 2108 Elevator(水~)
- ZOJ 2108 Elevator (模拟题)
- zoj 2108 Elevator
- ZOJ 2108 Elevator
- ZOJ 2108 Elevator
- ZOJ Problem Set–2108 Elevator
- ZOJ 2108 Elevator
- zoj 2108 Elevator
- poj3767
- ZOJ 2997 Black and White