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特别不喜欢那些随便转载别人的原创文章又不给 ...
随机推荐
- css关于内外边距的详细解释
贴图吧,图一眼明了. 无效果时候有 只有一个<div>啦啦啦</div> 只有padding时候有: padding详细设计时: 解释:padding是对内的,如padding ...
- 移植完linux-3.4.2内核,启动系统后使用命令ifconfig -a查看网络配置,没有eth0
问题: / # ifconfig / # ifconfig eth0 ifconfig: eth0: error fetching interface information: Device not ...
- Oracle---SQL子查询---详解
子查询其实就是指嵌入到其他语句中的select语句,也称其为嵌套查询. 值得注意的在DDL语句中应用子查询的时候子查询可以使用order by 子句. 但是在DML语句中的where子句,set子句中 ...
- oracle--视图(2)---
Oracle---视图 视图是基于一个表或多个表或视图的逻辑表,本身不包含数据,通过它可以对表里面的数据进行查询和修改.视图基于的表称为基表,Oracle的数据库对象分为五种:表,视图,序列,索引和同 ...
- C# 删除文件和目录到回收站
if (Directory.GetDirectories(projectPath).Length == 0 && Directory.GetFiles(projectPath).Len ...
- mongodb 分页(limit)
db.COLLECTION_NAME.find().limit(NUMBER) db.mycol.find().limit() db.mycol.find({},{,_id:}).limit().sk ...
- Springboot ResponseEntity IE无法正常下载文件
项目在google浏览器下都很nice了,但当测试到IE的时候开始出现各种问题. 项目是前端js通过URL传参fileName到后台解析返回ResponseEntity 前端代码如下: window. ...
- 9、scala函数式编程-集合操作
一.集合操作1 1.Scala的集合体系结构 // Scala中的集合体系主要包括:Iterable.Seq.Set.Map.其中Iterable是所有集合trait的根trai.这个结构与Java的 ...
- C# 将数组转换为以逗号分隔的字符串
例子: string[] array = { "A", "B", "C", "D" }; string str = st ...
- 浅谈JavaScript--事件委托与事件监听
事件监听 该方法用于向指定元素添加事件句柄(代码块),且不会覆盖已存在的事件句柄. 即可以向同一个元素添加同一个事件多次. 添加事件 语法: element.addEventListener(even ...