pat1083. List Grades (25)
1083. List Grades (25)
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 [grade1, grade2] 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<cstdio>
#include<stack>
#include<algorithm>
#include<iostream>
#include<stack>
#include<set>
#include<map>
using namespace std;
map<int,pair<string,string> > ha;//成绩-姓名-id
int main(){
//freopen("D:\\INPUT.txt","r",stdin);
int n;
scanf("%d",&n);
int i,g1,g2;
string name,id;
int grade;
for(i=;i<n;i++){
cin>>name>>id;
scanf("%d",&grade);
ha[grade]=make_pair(name,id);
}
int temp;
scanf("%d %d",&g1,&g2);
if(g1>g2){
temp=g1;
g1=g2;
g2=temp;
}
temp=;
map<int,pair<string,string> >::reverse_iterator it;
for(it=ha.rbegin();it!=ha.rend();it++){
if(it->first>=g1&&it->first<=g2){
cout<<(it->second).first<<" "<<(it->second).second<<endl;
temp++;
}
}
if(!temp){
printf("NONE\n");
}
return ;
}
pat1083. List Grades (25)的更多相关文章
- PAT1083:List Grades
1083. List Grades (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a l ...
- A1083 List Grades (25)(25 分)
A1083 List Grades (25)(25 分) Given a list of N student records with name, ID and grade. You are supp ...
- A1083 List Grades (25 分)
Given a list of N student records with name, ID and grade. You are supposed to sort the records with ...
- 【PAT甲级】1083 List Grades (25 分)
题意: 输入一个正整数N(<=101),接着输入N个学生的姓名,id和成绩.接着输入两个正整数X,Y(0<=X,Y<=100),逆序输出成绩在x,y之间的学生的姓名和id. tric ...
- 1083. List Grades (25)
the problem is from PAT,which website is http://pat.zju.edu.cn/contests/pat-a-practise/1083 and the ...
- PAT (Advanced Level) 1083. List Grades (25)
简单排序. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...
- 1083. List Grades (25)-简单的排序
给定区间[L,R],给出在这区间之内的学生,并且按照他们的成绩非升序的顺序输出. #include <iostream> #include <cstdio> #include ...
- PAT_A1083#List Grades
Source: PAT A1083 List Grades (25 分) Description: Given a list of N student records with name, ID an ...
- PAT甲级题解(慢慢刷中)
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...
随机推荐
- js数组中常用的几个API
1.push:从末尾添加数据项. 2.pop:从末尾去除数据项. 3.shift:从开始去除数据项 4.splice: splice(m,n) m:指开始删除的索引位置 n:值删除几项 splice ...
- 存储引擎InnoDB
InnoDB是MySQL的默认存储引擎, InnoDB支持的最大存储限制是64TB,支持事务安全,支持行锁,支持B树索引,不支持哈希索引和全文索引,支持集群索引,支持数据缓存,支持索引缓存,不支持数据 ...
- 如何保持blog的高质量(相对于自己的进步而言的)
多写! 多改!! 多删!!!
- JSONCPP学习笔记
基本使用 使用jsoncpp库解析.修改.打印JSON串 源文件 $ cat main.cpp #include <iostream> #include "json/json.h ...
- 边界提取_MATLAB
下面是利用腐蚀算法进行边界提取,即原图减去腐蚀后的图得到边界 f=imread('D:/picture/ZiXia.jpg'); figure; subplot(,,); imshow(f); tit ...
- Codeforces Round #527 (Div. 3)D2(栈,思维)
#include<bits/stdc++.h>using namespace std;int a[200007];stack<int>s;int main(){ int ...
- 从零开始安装 Ambari (2) -- 准备本地 repository
安装 Ambari,最后是为了用它部署 hadoop 集群.安装时默认使用的是 hortonworks 远程的资源,用它部署集群时,需要下载 Hadoop.Hive.HBase 的安装包,速度很慢.我 ...
- 分别使用ES5和ES6进行数组去重以及注意事项
ES6,ES5数组去重 使用Es6进行数组去重 var arr = [false, true, undefined, null, NaN, 0, 1, {}, {}, 'a', 'a', NaN]; ...
- Python使用Zero-Copy和Buffer Protocol实现高性能编程
无论你程序是做什么的,它经常都需要处理大量的数据.这些数据大部分表现形式为strings(字符串).然而,当你对字符串大批量的拷贝,切片和修改操作时是相当低效的.为什么? 让我们假设一个读取二进制数据 ...
- shell学习(14)- who
Linux who命令用于显示系统中有哪些使用者正在上面,显示的资料包含了使用者 ID.使用的终端机.从哪边连上来的.上线时间.呆滞时间.CPU 使用量.动作等等. 使用权限:所有使用者都可使用. 语 ...