ZOJ 3767-Elevator

素颜马尾好姑娘i 2022-08-20 14:11 241阅读 0赞

B - Elevator

Crawling in process… Crawling failed

Time Limit: 2000MS Memory Limit: 65536KB 64bit IO Format: %lld & %llu

Submit Status Practice ZOJ 3767

Appoint description: System Crawler (2016-03-02)

Description

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

  1. 2
  2. 3 800
  3. 50 60 70
  4. 9 800
  5. 50 55 60 60 60 60 65 70 360

Sample Output

  1. Safe
  2. Warning
  3. #include<stdio.h>
  4. int main()
  5. {
  6. int T;
  7. scanf("%d",&T);
  8. while(T--)
  9. {
  10. int n,w;
  11. scanf("%d%d",&n,&w);
  12. int i,j;
  13. j=0;
  14. for(i=0;i<n;i++)
  15. {
  16. int o;
  17. scanf("%d",&o);
  18. j+=o;
  19. }
  20. if(j<=w)
  21. printf("Safe\n");
  22. else
  23. {
  24. printf("Warning\n");
  25. }
  26. }
  27. return 0;
  28. }

发表评论

表情:
评论列表 (有 0 条评论,241人围观)

还没有评论,来说两句吧...

相关阅读