Given a list of N student records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the grades are in a given interval.

Input Specification:

Each input file contains one test case. Each case is given in the following format:

N
name[1] ID[1] grade[1]
name[2] ID[2] grade[2]
... ...
name[N] ID[N] grade[N]
grade1 grade2

where name[i] and ID[i] are strings of no more than 10 characters with no space, grade[i] is an integer in [0, 100], grade1 and grade2 are the boundaries of the grade's interval. It is guaranteed that all the grades are distinct.

Output Specification:

For each test case you should output the student records of which the grades are in the given interval [grade1grade2] and are in non-increasing order. Each student record occupies a line with the student's name and ID, separated by one space. If there is no student's grade in that interval, output NONE instead.

Sample Input 1:

4
Tom CS000001 59
Joe Math990112 89
Mike CS991301 100
Mary EE990830 95
60 100

Sample Output 1:

Mike CS991301
Mary EE990830
Joe Math990112

Sample Input 2:

2
Jean AA980920 60
Ann CS01 80
90 95

Sample Output 2:

NONE
 #include <iostream>
#include <string>
#include <algorithm>
using namespace std;
struct Node
{
string name, id;
int grade;
};
int main()
{
int N, grade1, grade2;
cin >> N;
Node* data = new Node[N];
for (int i = ; i < N; ++i)
cin >> data[i].name >> data[i].id >> data[i].grade;
cin >> grade1 >> grade2;
sort(data, data + N, [](Node a, Node b) {return a.grade > b.grade; });
int flag = ;
for (int i = ; i < N; ++i)
{
if (data[i].grade < grade1)
break;
if (data[i].grade >= grade1 && data[i].grade <= grade2)
{
cout << data[i].name << " " << data[i].id << endl;
flag = ;
}
}
if (flag == )
cout << "NONE" << endl;
delete[]data;
return ;
}

PAT甲级——A1083 List Grades的更多相关文章

  1. PAT 甲级 1083 List Grades (25 分)

    1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...

  2. PAT 甲级 1083 List Grades

    https://pintia.cn/problem-sets/994805342720868352/problems/994805383929905152 Given a list of N stud ...

  3. PAT甲级题解(慢慢刷中)

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  4. 【转载】【PAT】PAT甲级题型分类整理

    最短路径 Emergency (25)-PAT甲级真题(Dijkstra算法) Public Bike Management (30)-PAT甲级真题(Dijkstra + DFS) Travel P ...

  5. PAT甲级题分类汇编——排序

    本文为PAT甲级分类汇编系列文章. 排序题,就是以排序算法为主的题.纯排序,用 std::sort 就能解决的那种,20分都算不上,只能放在乙级,甲级的排序题要么是排序的规则复杂,要么是排完序还要做点 ...

  6. PAT甲级题分类汇编——序言

    今天开个坑,分类整理PAT甲级题目(https://pintia.cn/problem-sets/994805342720868352/problems/type/7)中1051~1100部分.语言是 ...

  7. PAT甲级题解分类byZlc

    专题一  字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...

  8. 1080 Graduate Admission——PAT甲级真题

    1080 Graduate Admission--PAT甲级练习题 It is said that in 2013, there were about 100 graduate schools rea ...

  9. PAT甲级:1036 Boys vs Girls (25分)

    PAT甲级:1036 Boys vs Girls (25分) 题干 This time you are asked to tell the difference between the lowest ...

随机推荐

  1. android:两个应用之间怎样传值之activity

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/zjh171/article/details/37738579 两个应用之间怎样传值.事实上这个标题太 ...

  2. 常见PID里面的像素大小

    因为tensorflow/models里faster R-cnn目前识别的好像是按照像素比上图片大小来识别的,所以在这里统计一下各个元件的像素大小的范围 DCS:70~200

  3. 神经网络 (2)- Alexnet Training on MNIST

    文章目录 Win10 Anaconda下配置tensorflow+jupyter notebook环境 AlexNet 识别MNIST Win10 Anaconda下配置tensorflow+jupy ...

  4. 笔记23 搭建Spring MVC

    搭建一个最简单的SpringMVC示例 1.配置DispatcherServlet DispatcherServlet是Spring MVC的核心.在这里请求会第一次 接触到框架,它要负责将请求路由到 ...

  5. COGS2353 【HZOI2015】有标号的DAG计数 I

    题面 题目描述 给定一正整数n,对n个点有标号的有向无环图(可以不连通)进行计数,输出答案mod 10007的结果 输入格式 一个正整数n 输出格式 一个数,表示答案 样例输入 3 样例输出 25 提 ...

  6. 纯PHP Codeigniter(CI) ThinkPHP效率测试

    最近一直想做一个技术类的新闻站点,想做的执行效率高些,想用PHP做,一直纠结于用纯PHP做还是用CI或者THINKPHP.用纯PHP效率高,缺点 n多,比如安全方面.构架方面等等等等:用CI.thin ...

  7. CF421D Bug in Code

    题意:n个人每人选择了另外不相同的两个人.问有多少对(x,y)使得这n个人中至少有p个选择了至少其中之一? 标程:那就不写了吧. 题解:容斥 统计Ax表示有多少个人选择了x. 一般来说有Ax+Ay&g ...

  8. Windows 子网掩码

    子网掩码(subnet mask)又叫网络掩码.地址掩码.子网络遮罩,它是一种用来指明一个IP地址的哪些位标识的是主机所在的子网,以及哪些位标识的是主机的位掩码.子网掩码不能单独存在,它必须结合IP地 ...

  9. 概率+后效性处理——cf930B好题

    之前题目看错了.. 先用双倍字符串处理后效性 首先要确定一个结论:如果原串s中相距为d的ch1和ch2只有一对,那么如果第一个翻开ch1,第二个翻开ch2,就能确定k 现在要求的是当我们第一次翻开的是 ...

  10. VC中隐藏和显示IDC_STATIC

    void CImageShowAndHideDlg::OnBnClickedButton1() //隐藏 {       CWnd* pWnd = GetDlgItem(IDC_STATIC);    ...