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. 【POJ】3660 Cow Contest

    题目链接:http://poj.org/problem?id=3660 题意:n头牛比赛,有m场比赛,两两比赛,前面的就是赢家.问你能确认几头牛的名次. 题解:首先介绍个东西,传递闭包,它可以确定尽可 ...

  2. 【校OJ】选网线

    暑假学校OJ上的题目. 一道很有意思的二分. 题意:三个数组,每个数组各选一个数出来看是否能组成目标数. 题解:前两个数组两两的和组合一下,二分第三个数组,找是否能组成目标数. 代码: #includ ...

  3. (十三)在ASP.NET CORE中使用Options

    这一节介绍Options方法,继续在OptionsBindSample项目下. 在项目中添加一个Controllers文件夹,文件夹添加一个HomeController控制器 HomeControll ...

  4. iOS开发系列-Foundation与CoreFoundation内存管理

    概述 对于初学者来说,可能仅只能将ARC用在objective-c对象上(也即继承自NSObject的对象),但是如果涉及到较为底层的东西,比如Core Foundation中的malloc()或者f ...

  5. flex:1将页面铺满

    代码示范: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...

  6. android studio 一个项目如何打包多个apk

    1.修改app的build.gradle文件 假设我们同一套代码编译2个app:demo1和demo2 android { ... productFlavors { // demo1 demo1 { ...

  7. 【JZOJ4616】二进制的世界

    description analysis \(DP\),这是\(Claris\)神仙的题-? 既然是\(2^{16}\)可以拆成两个\(2^8\)的位运算 照着打就行了 code #include&l ...

  8. lombok使用手册

    lombok使用手册: 1.安装插件 1.1.idel: 1.2.使用lombok还需要引用相关jar包 参考网址:https://projectlombok.org/features/all 2.注 ...

  9. python3和python2编码拾遗

    py2编码 tr和unicode str和unicode都是basestring的子类.严格意义上说,str其实是字节串,它是unicode经过编码后的字节组成的序列.对UTF-8编码的str'苑'使 ...

  10. pom parent 标签

    <!--parent用于引用父工程 1.统一管理jar包的版本,其依赖需要在子工程中定义才有效(比如此例) 2.统一的依赖管理(父工程的<dependencies>,子工程不必重新引 ...