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特别不喜欢那些随便转载别人的原创文章又不给 ...
随机推荐
- day02 秘钥生成,免密访问命令
hadoop免密登陆: 生成秘钥: ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa cat ~/.ssh/id_dsa.pub >> ~/.ssh/aut ...
- (转)Maven 项目新建index.jsp报错问题
原文:http://blog.csdn.net/dream_ll/article/details/52198656 最近用eclipse新建了一个maven项目,结果刚新建完成index.jsp页面就 ...
- 关于SCANF接受的一些总结
当C语言中SCANF函数接受到非指定类型的参数时,如:定义为整形输入为字符串,函数会返回一个失败的BOOL类型,以此可以判断是否输入的为指定类型. 当发生一次输入错误的时候,如果想再次进行输入则需要使 ...
- docker启动
启动容器 启动容器有两种方式,一种是基于镜像新建一个容器并启动,另外一个是将在终止状态(stopped)的容器重新启动. 因为 Docker 的容器实在太轻量级了,很多时候用户都是随时删除和新创建容器 ...
- p1640&bzoj1854 连续攻击游戏(游戏)
传送门(洛谷) 传送门(bzoj) 题目 lxhgww最近迷上了一款游戏,在游戏里,他拥有很多的装备,每种装备都有2个属性,这些属性的值用[1,10000]之间的数表示.当他使用某种装备时,他只能使用 ...
- C# 中介者模式
中介者模式 中介者模式,定义了一个中介对象来封装一系列对象之间的交互关系.中介者使各个对象之间不需要显式地相互引用,从而使耦合性降低,而且可以独立地改变它们之间的交互行为. 结构: 中介者模式设计两个 ...
- vue中通过cross-env插件配置三种环境(开发,测试,生产)打包,不用切换api
1. 话不多说,第一步就是安装必要的插件 npm install cross-env --save 2.修改config里面的参数,这里只展示一个test,其他类似 3.修改package.json ...
- Linux之shell备份数据库
功能概述: 使用shell脚本对服务器的数据库(全部或指定数据库)进行备份.对15天(固定天数)之前的数据库备份进行删除 命令实现: 待定
- 为什么要使用func.call(this)
1.为什么要使用func.call(this) 在正常模式下,js 函数里那些你没有声明就使用的变量,其实是访问的全局对象的属性.但是在严格模式下,不允许这种语法,所有变量都必须要显示声明,所以如果你 ...
- 浅谈UML——九种图(一)
前言 学UML将近两个星期了,对UML有了一定的了解,学过的没学过的都知道UML中最最最核心的部分要数那九个图了.浅谈UML九种图. 实例 1.用例图: 什么是用例?描绘一个系统外在可见的需求情况,是 ...