2014ACM集训13级PK赛5-Faster, Higher, Stronger
2014-03-16 19:59
211 查看
Description
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 integerT (1 <=
T <= 50) which is the number of test cases. And it will be followed byT 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 integerN meaning the number of the records in this test case. The third line hasN 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
faster找最小值,其他找最大值。
Sample Output
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 integerT (1 <=
T <= 50) which is the number of test cases. And it will be followed byT 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 integerN meaning the number of the records in this test case. The third line hasN 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
faster找最小值,其他找最大值。
3 Faster 3 10 11 12 Higher 4 3 5 4 2 Stronger 2 200 200
Sample Output
10 5 200
#include <string.h> #include <stdio.h> #include <math.h> #include <stdlib.h> int num[3000]; int cmp1 (const void *a,const void *b) { return *(int *)a - *(int *)b; } int cmp2 (const void *a,const void *b) { return *(int *)b - *(int *)a; } int main() { int N; scanf ("%d",&N); while (N--) { char s[100]; scanf ("%s",s); int n,i; if (!strcmp (s,"Faster")) { scanf ("%d",&n); for (i = 0;i < n;i++) scanf ("%d",&num[i]); qsort (num,n,sizeof (num[0]),cmp1); }else if (!strcmp (s,"Higher")) { scanf ("%d",&n); for (i = 0;i < n;i++) scanf ("%d",&num[i]); qsort (num,n,sizeof (num[0]),cmp2); }else if (!strcmp (s,"Stronger")) { scanf ("%d",&n); for (i = 0;i < n;i++) scanf ("%d",&num[i]); qsort (num,n,sizeof (num[0]),cmp2); } printf ("%d\n",num[0]); } return 0; }
相关文章推荐
- 2014ACM集训13级PK赛4-K-Nice
- 2014ACM集训13级PK赛3-Draw Something Cheat
- 2014ACM集训13级PK赛4-Light Bulb
- 2014ACM集训13级PK赛2-Who is Older?
- 2014ACM集训13级PK赛3-Modular Inverse
- 2014ACM集训13级PK赛2-Somali Pirates
- 2014ACM集训13级PK赛3-Yet Another Story of Rock-paper-scissors
- 2014ACM集训13级PK赛2-An Awful Problem
- 2014ACM集训13级PK赛3-Break Standard Weight
- 2014ACM集训13级PK赛5- Accurately Say "CocaCola"!
- 2014ACM集训13级PK赛2-Wu Xing
- 2014ACM集训13级PK赛3-Friends
- 2014ACM集训13级PK赛5-Easy Task
- 2014ACM集训13级PK赛2-Ordinal Numbers
- 2014ACM集训13级PK赛3-Hard to Play
- 2014ACM集训13级PK赛5-Give Me the Number
- 2014ACM集训13级PK赛2-Conic Section
- 2014ACM集训13级PK赛3-Java Beans
- 2014ACM集训13级PK赛2-Kagome Kagome
- 2014ACM集训13级PK赛2-Javabeans