zoj 2970
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 T consecutive 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
//2970
#include <iostream>
using namespace std;
int main()
{
char s[8];
int t;
cin>>t;
while(t--)
{
scanf("%s",s);
int n;
if(strcmp(s,"Faster")==0)
{
int f = 1000000;
int x;
cin>>n;
while(n--)
{
cin>>x;
if(x<f)
f=x;
}
cout<<f<<endl;
}
else
{
int m = 0;
int x;
cin>>n;
while(n--)
{
cin>>x;
if(x>m)
m = x;
}
cout<<m<<endl;
}
}
return 0;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
cocos2d Lua 학습(一)ios에서 루아 함수 호출 및 전참 방법 lua 코드: 출력 결과: lua 호출 C++ 방법: add 함수: lua 코드: 출력 결과: 함수를 호출합니다. 함수를 호출하려면 다음 협의를 따르십시오. 우선, 호출할 함...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.