https://pintia.cn/problem-sets/994805342720868352/problems/994805383929905152

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 <bits/stdc++.h>
using namespace std; const int maxn = 1e5 + 10;
int N;
int L, R; struct Node{
char name[15];
char id[15];
int score;
}node[maxn]; bool cmp(const Node& a, const Node& b) {
return a.score > b.score;
} int main() {
scanf("%d", &N);
for(int i = 0; i < N; i ++)
scanf("%s%s%d", node[i].name, node[i].id, &node[i].score);
scanf("%d%d", &L, &R);
sort(node, node + N, cmp);
int cnt = 0;
for(int i = 0; i < N; i ++) {
if(node[i].score >= L && node[i].score <= R) {
cnt ++;
printf("%s %s\n", node[i].name, node[i].id);
}
}
if(!cnt) printf("NONE\n");
return 0;
}

 真滴是很久不见啦!

PAT 甲级 1083 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甲级——A1083 List Grades

    Given a list of N student records with name, ID and grade. You are supposed to sort the records with ...

  3. PAT 1083 List Grades[简单]

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

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

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

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

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

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

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

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

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

  8. PAT 甲级真题题解(63-120)

    2019/4/3 1063 Set Similarity n个序列分别先放进集合里去重.在询问的时候,遍历A集合中每个数,判断下该数在B集合中是否存在,统计存在个数(分子),分母就是两个集合大小减去分 ...

  9. PAT甲级目录

    树(23) 备注 1004 Counting Leaves   1020 Tree Traversals   1043 Is It a Binary Search Tree 判断BST,BST的性质 ...

随机推荐

  1. 第六节 Go数据结构之集合

    一.什么是集合 集合就是不同对象的无序聚集.那么链表和集合有什么关系呢?我们来变个魔术.如下图是各种颜色组成的链表: 下面我们一步步把链表变成集合. 第一步砍去链接 第二步去掉重复 第三步放到一个框里 ...

  2. 重学Verilog(1)

    1.线与.线或功能 wor module WO(A, B, C, D, WireOR) input A,B,C,D; output WireOr; wor WireOr; assign WireOr ...

  3. Linux入门——基础系统设置命令

    以下为centos7实验环境 1.网卡管理工具命令——nmcli 参考:http://www.iteye.com/topic/1141839 2.主机名称设置——hostnamectl [root@s ...

  4. flex 自定义tooltip

    //flex用例网址 http://thanksmister.com/2012/01/18/flex-chart-datatip-renderer/ http://help.adobe.com/en_ ...

  5. 20155328 2016-2017-2 《Java程序设计》 第一周学习总结

    20155328 2016-2017-2 <Java程序设计> 第一周学习总结 教材学习内容总结 本周学习目标是浏览<Java学习笔记>中的十八章,其中第一章和第二章认真学习, ...

  6. 1009 产生数 2002年NOIP全国联赛普及组

    1009 产生数 2002年NOIP全国联赛普及组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold   题目描述 Description 给出一个整数 n(n< ...

  7. Windows下使用Python的Curses库时 No module named _curses问题

    这个问题产生的 根本原因 是 curses 库不支持 windows.所以我们在下载完成python后(python 是自带 curses 库的),虽然在  python目录\Lib  中可以看到 c ...

  8. Python接口测试实战2 - 使用Python发送请求

    如有任何学习问题,可以添加作者微信:lockingfree 课程目录 Python接口测试实战1(上)- 接口测试理论 Python接口测试实战1(下)- 接口测试工具的使用 Python接口测试实战 ...

  9. 微信小程序转换为百度小程序

    据粗略预估,微信小程序和百度小程序,有至少90%以上的相似代码,而且api的参数和返回的数据都是一致的,有一些不一致的将做如下介绍:.wxml文件,改成后辍名.swan.wxss文件,改成后辍名为.c ...

  10. JAVA学习笔记--迭代器

    迭代器(Iterator)是一种设计模式.它是一个对象,它的工作是遍历并选择序列中的对象,而客户端程序员不必知道或关心该序列底层的结构.创建迭代器的代价小,因而迭代器通常被称为轻量级对象. 一.Ite ...