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:

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

思路
要求按成绩降序输出给定成绩区间学生的信息。考虑到成绩不超过100而且唯一,可以用桶排序的思想来直接排序输出而不用比较。
1.用两种桶name[101]和ID[101]分别存放姓名和ID。
2.用成绩代表桶的下标,把对应成绩的学生信息放入桶中。如Jack CS00001 60 ---等价于---> name[60] = "Jack", ID[60] = "CS00001"。
3.根据区间范围输出不为空的桶里面的信息即可。如果范围内的桶都为空输出"NONE"。
代码
#include<iostream>
#include<vector>
#include<string>
using namespace std;
vector<string> name();
vector<string> ID(); int main()
{
int N;
while(cin >> N)
{
string n,id;
for(int i = ;i < N;i++)
{
int grade;
cin >> n >> id >> grade;
name[grade] = n;
ID[grade] = id;
}
int j,k;
bool isNone = true;
cin >> j >> k;
for(;k >= j;k--)
{
if(name[k] != "")
{
isNone = false;
cout << name[k] << " " << ID[k] << endl;
}
}
if(isNone)
cout <<"NONE" << endl;
ID.clear();
name.clear();
}
}
 

PAT1083:List Grades的更多相关文章

  1. pat1083. List Grades (25)

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

  2. PAT 甲级 1083 List Grades (25 分)

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

  3. A1083. List Grades

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

  4. Taking water into exams could boost grades 考试带瓶水可以提高成绩?

    Takeing a bottle of water into the exam hall could help students boost their grades, researchers cla ...

  5. PAT 1083 List Grades[简单]

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

  6. PAT 甲级 1083 List Grades

    https://pintia.cn/problem-sets/994805342720868352/problems/994805383929905152 Given a list of N stud ...

  7. PAT 1083 List Grades

    #include <cstdio> #include <cstdlib> using namespace std; class Stu { public: ]; ]; }; i ...

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

  9. A1083 List Grades (25 分)

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

随机推荐

  1. 优雅的App完全退出方案(没有任何内存泄漏隐患)

    在Android开发过程中,特别是界面比较多的情况下,用平常的退出方式往往是不能完全退出这个应用,网络上也好多各种退出方案.其中一种应该是被广大开发者采纳使用,也非常的清晰方便,就是在Applicat ...

  2. 【翻译】在Ext JS应用程序中使用自定义图标

    原文:Using Custom Icons in Your Ext JS App 作者:Lee BoonstraLee is a technical trainer at Sencha. She's ...

  3. 粒子系统属性Life,发射速率和总数的关系

    提示,粒子系统的life,发射速率以及总粒子数是相互影响的. 如果你要发射器射出粒子流然后停顿一会,你将简单的必须确保lifetime和发射速率相匹配以至于在发射出的粒子达到粒子总数之前一些粒子是活跃 ...

  4. node.js 的url模块

    var URL = require('url');  var testUrl = "http://www.baidu.com:8080/index.php?content=abc" ...

  5. TCP中的MSS解读(转)

    本文摘录自TCP中的MSS解读. MSS 是TCP选项中最经常出现,也是最早出现的选项.MSS选项占4byte.MSS是每一个TCP报文段中数据字段的最大长度,注意:只是数据部分的字段,不包括TCP的 ...

  6. java 项目得到jar和classes路径

    java 项目得到jar和classes路径 public static String getJarPath(Class clazz) { String path = clazz.getProtect ...

  7. C#中任意类型数据转成JSON格式

    /// <summary>    /// List转成json     /// </summary>    /// <typeparam name="T&quo ...

  8. PHP 查询脚本

    POST查询以表格传参数支持中文,GET不支持. POST查询: <?php $id=$_POST["id"];//id(中括号)为传来的参数,$id为php中的变量 //l ...

  9. android + php 后台开发

    android+php 安卓与服务器的数据交互 在我们进行android开发的时候,避免不了的要进行登录注册,个人信息获取,数据交互等等这一系列的操作.这样就需要进行android端与服务器端进行数据 ...

  10. js获取Session的值

    纯htm页面必须采用AJAX了, ASP页面:var manager='<%=session("manager")%>', ASPX页面:var manager='&l ...