zoukankan      html  css  js  c++  java
  • ZOJ Problem Set 2970 Faster, Higher, Stronger

    ZOJ Problem Set - 2970
    Faster, Higher, Stronger

    Time Limit: 1 Second      Memory Limit: 32768 KB

    In the year 2008, the 29th Olympic Games will be held in Beijing. This will signify the prosperity of China and Beijing Olympics is to be a festival for people all over the world as well.

    The motto of Olympic Games is "Citius, Altius, Fortius", which means "Faster, Higher, Stronger".

    In this problem, there are some records in the Olympic Games. Your task is to find out which one is faster, which one is higher and which one is stronger.

    Input

    Standard input will contain multiple test cases. The first line of the input is a single integer T (1 <= T <= 50) which is the number of test cases. And it will be followed by Tconsecutive test cases.

    Each test case has 3 lines. The first line is the type of the records, which can only be "Faster" "Higher" or "Stronger". The second line is a positive integer N meaning the number of the records in this test case. The third line has N positive integers, i.e. the records data. All the integers in this problem are smaller than 2008.

    Output

    Results should be directed to standard output. The output of each test case should be a single integer in one line. If the type is "Faster", the records are time records and you should output the fastest one. If the type is "Higher", the records are length records. You should output the highest one. And if the type is "Stronger", the records are weight records. You should output the strongest one.

    Sample Input

    3
    Faster
    3
    10 11 12
    Higher
    4
    3 5 4 2
    Stronger
    2
    200 200
    

    Sample Output

    10
    5
    200
    

    Author: XUE, Zaiyue
    Source: The 5th Zhejiang Provincial Collegiate Programming Contest
    SOURCE CODE:
    #include<iostream>
    #include
    <string>
    #include
    <limits>

    using namespace std;

    int main()
    {
    int cases;
    cin
    >>cases;
    while(cases--)
    {
    string command;cin>>command;
    unsigned records;cin
    >>records;
    if(command == "Faster")
    {
    unsigned min
    = std::numeric_limits<unsigned>::max();
    int record;
    while(records--)
    {
    cin
    >>record;
    if(record < min)
    {
    min
    = record;
    }
    }
    cout
    <<min<<endl;
    }
    else if(command == "Higher" || command == "Stronger")
    {
    unsigned max
    = std::numeric_limits<unsigned>::min();
    int record;
    while(records--)
    {
    cin
    >>record;
    if(record > max)
    {
    max
    = record;
    }
    }
    cout
    <<max<<endl;
    }
    }
    return 0;
    }

  • 相关阅读:
    《海思VPSS — 将1920*1080图像通过VPSS缩放旋转成800*1280在LCD上显示》
    《Shell编程实例 —— 自动检测并挂载硬盘》
    《Shell脚本学习 —— 运算符、输入/输出重定向》
    《Shell脚本学习 —— 函数、文件包含》
    《Shell脚本学习 —— 流程控制if、for、while、无限循环、until、case、跳出循环》
    《Shell脚本学习 —— Shell传递参数、echo命令、test命令》
    牛客多校第三场 A—pacm team (4维背包加路径压缩)
    牛客第二场Dmoney
    牛客第二场A-run
    牛客第二场A-run
  • 原文地址:https://www.cnblogs.com/malloc/p/2096314.html
Copyright © 2011-2022 走看看