1083. List Grades (25)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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:

  1. N
  2. name[1] ID[1] grade[1]
  3. name[2] ID[2] grade[2]
  4. ... ...
  5. name[N] ID[N] grade[N]
  6. 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:

  1. 4
  2. Tom CS000001 59
  3. Joe Math990112 89
  4. Mike CS991301 100
  5. Mary EE990830 95
  6. 60 100

Sample Output 1:

  1. Mike CS991301
  2. Mary EE990830
  3. Joe Math990112

Sample Input 2:

  1. 2
  2. Jean AA980920 60
  3. Ann CS01 80
  4. 90 95

Sample Output 2:

  1. NONE

提交代码

  1. #include<cstdio>
  2. #include<stack>
  3. #include<algorithm>
  4. #include<iostream>
  5. #include<stack>
  6. #include<set>
  7. #include<map>
  8. using namespace std;
  9. map<int,pair<string,string> > ha;//成绩-姓名-id
  10. int main(){
  11. //freopen("D:\\INPUT.txt","r",stdin);
  12. int n;
  13. scanf("%d",&n);
  14. int i,g1,g2;
  15. string name,id;
  16. int grade;
  17. for(i=;i<n;i++){
  18. cin>>name>>id;
  19. scanf("%d",&grade);
  20. ha[grade]=make_pair(name,id);
  21. }
  22. int temp;
  23. scanf("%d %d",&g1,&g2);
  24. if(g1>g2){
  25. temp=g1;
  26. g1=g2;
  27. g2=temp;
  28. }
  29. temp=;
  30. map<int,pair<string,string> >::reverse_iterator it;
  31. for(it=ha.rbegin();it!=ha.rend();it++){
  32. if(it->first>=g1&&it->first<=g2){
  33. cout<<(it->second).first<<" "<<(it->second).second<<endl;
  34. temp++;
  35. }
  36. }
  37. if(!temp){
  38. printf("NONE\n");
  39. }
  40. return ;
  41. }

pat1083. List Grades (25)的更多相关文章

  1. PAT1083:List Grades

    1083. List Grades (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a l ...

  2. 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 ...

  3. A1083 List Grades (25 分)

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

  4. 【PAT甲级】1083 List Grades (25 分)

    题意: 输入一个正整数N(<=101),接着输入N个学生的姓名,id和成绩.接着输入两个正整数X,Y(0<=X,Y<=100),逆序输出成绩在x,y之间的学生的姓名和id. tric ...

  5. 1083. List Grades (25)

    the problem is from PAT,which website is http://pat.zju.edu.cn/contests/pat-a-practise/1083 and the ...

  6. PAT (Advanced Level) 1083. List Grades (25)

    简单排序. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...

  7. 1083. List Grades (25)-简单的排序

    给定区间[L,R],给出在这区间之内的学生,并且按照他们的成绩非升序的顺序输出. #include <iostream> #include <cstdio> #include ...

  8. PAT_A1083#List Grades

    Source: PAT A1083 List Grades (25 分) Description: Given a list of N student records with name, ID an ...

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

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

随机推荐

  1. day02 秘钥生成,免密访问命令

    hadoop免密登陆: 生成秘钥: ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa cat ~/.ssh/id_dsa.pub >> ~/.ssh/aut ...

  2. (转)Maven 项目新建index.jsp报错问题

    原文:http://blog.csdn.net/dream_ll/article/details/52198656 最近用eclipse新建了一个maven项目,结果刚新建完成index.jsp页面就 ...

  3. 关于SCANF接受的一些总结

    当C语言中SCANF函数接受到非指定类型的参数时,如:定义为整形输入为字符串,函数会返回一个失败的BOOL类型,以此可以判断是否输入的为指定类型. 当发生一次输入错误的时候,如果想再次进行输入则需要使 ...

  4. docker启动

    启动容器 启动容器有两种方式,一种是基于镜像新建一个容器并启动,另外一个是将在终止状态(stopped)的容器重新启动. 因为 Docker 的容器实在太轻量级了,很多时候用户都是随时删除和新创建容器 ...

  5. p1640&bzoj1854 连续攻击游戏(游戏)

    传送门(洛谷) 传送门(bzoj) 题目 lxhgww最近迷上了一款游戏,在游戏里,他拥有很多的装备,每种装备都有2个属性,这些属性的值用[1,10000]之间的数表示.当他使用某种装备时,他只能使用 ...

  6. C# 中介者模式

    中介者模式 中介者模式,定义了一个中介对象来封装一系列对象之间的交互关系.中介者使各个对象之间不需要显式地相互引用,从而使耦合性降低,而且可以独立地改变它们之间的交互行为. 结构: 中介者模式设计两个 ...

  7. vue中通过cross-env插件配置三种环境(开发,测试,生产)打包,不用切换api

    1. 话不多说,第一步就是安装必要的插件 npm install cross-env --save 2.修改config里面的参数,这里只展示一个test,其他类似 3.修改package.json ...

  8. Linux之shell备份数据库

    功能概述: 使用shell脚本对服务器的数据库(全部或指定数据库)进行备份.对15天(固定天数)之前的数据库备份进行删除 命令实现: 待定

  9. 为什么要使用func.call(this)

    1.为什么要使用func.call(this) 在正常模式下,js 函数里那些你没有声明就使用的变量,其实是访问的全局对象的属性.但是在严格模式下,不允许这种语法,所有变量都必须要显示声明,所以如果你 ...

  10. 浅谈UML——九种图(一)

    前言 学UML将近两个星期了,对UML有了一定的了解,学过的没学过的都知道UML中最最最核心的部分要数那九个图了.浅谈UML九种图. 实例 1.用例图: 什么是用例?描绘一个系统外在可见的需求情况,是 ...