PAT (Advanced Level) Practise 1036 Boys vs Girls (25)
来源:互联网 发布:手机淘宝个人主页在哪 编辑:程序博客网 时间:2024/05/16 01:11
1036. Boys vs Girls (25)
This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.
Input Specification:
Each input file contains one test case. Each case contains a positive integer N, followed by N lines of student information. Each line contains a student's name, gender, ID and grade, separated by a space, where name and ID are strings of no more than 10 characters with no space, gender is either F (female) or M (male), and grade is an integer between 0 and 100. It is guaranteed that all the grades are distinct.
Output Specification:
For each test case, output in 3 lines. The first line gives the name and ID of the female student with the highest grade, and the second line gives that of the male student with the lowest grade. The third line gives the difference gradeF-gradeM. If one such kind of student is missing, output "Absent" in the corresponding line, and output "NA" in the third line instead.
Sample Input 1:
3Joe M Math990112 89Mike M CS991301 100Mary F EE990830 95Sample Output 1:
Mary EE990830Joe Math9901126Sample Input 2:
1Jean M AA980920 60Sample Output 2:
AbsentJean AA980920NA
简单题
#include<cstdio>#include<cstring>#include<string>#include<queue>#include<stack>#include<cmath>#include<algorithm>#include<functional>using namespace std;typedef long long LL;const int maxn = 1e3 + 10;int n, score[maxn], a, b;char name[maxn][20], id[maxn][20], gender[10];int main(){scanf("%d", &n);for (int i = 1; i <= n; i++){scanf("%s%s%s%d", name[i], gender, id[i], &score[i]);if (gender[0] == 'M' && (!a || score[i] < score[a])) a = i;if (gender[0] == 'F' && (!b || score[i] > score[b])) b = i;}if (b) printf("%s %s\n", name[b], id[b]); else printf("Absent\n");if (a) printf("%s %s\n", name[a], id[a]); else printf("Absent\n");if (!a || !b) printf("NA\n"); else printf("%d\n", score[b] - score[a]);return 0;}
- PAT (Advanced Level) Practise 1036 Boys vs Girls (25)
- PAT (Advanced Level) Practise 1036 Boys vs Girls (25)
- 1036. Boys vs Girls (25)【水题】——PAT (Advanced Level) Practise
- Pat(Advanced Level)Practice--1036(Boys vs Girls))
- 【C++】PAT(advanced level)1036. Boys vs Girls (25)
- 【PAT (Advanced Level)】1036. Boys vs Girls (25)
- PAT (Advanced Level) 1036. Boys vs Girls (25) 解题报告
- 【PAT】【Advanced Level】1036. Boys vs Girls (25)
- PAT (Advanced Level) 1036. Boys vs Girls (25) 结构体排序
- PAT 1036 Boys vs Girls (25)
- pat 1036 Boys vs Girls
- PAT 1036 Boys vs Girls
- PAT (Advanced Level) Practise 1036
- 1036. Boys vs Girls (25)-PAT
- 【PAT】1036. Boys vs Girls (25)
- PAT 1036. Boys vs Girls (25)
- PAT A 1036. Boys vs Girls (25)
- PAT 1036. Boys vs Girls (25)
- Vulkan入门学习
- Linux驱动相关命令:
- OpenCV3.1 xfeatures2d::SIFT 使用
- 史上最详细的Android Studio系列教程三--快捷键
- oracle10g rac stream 多表复制(本地捕获)
- PAT (Advanced Level) Practise 1036 Boys vs Girls (25)
- PHP通过字符串调用函数的代码
- Android开发学习之路--RxAndroid之操作符
- 让人蛋疼的KMP算法
- 测试用例管理之 TestLink
- Linux 多进程编程
- asp.net笔试题
- 线性适应元 - Adaptive Linear Element
- iOS多线程详细使用