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. Android For JNI(四)——C的数组,指针长度,堆内存和栈内存,malloc,学生管理系统

    Android For JNI(四)--C的数组,指针长度,堆内存和栈内存,malloc,学生管理系统 好几天每写JNI了,现在任务也越来越重了,工作的强度有点高,还有好几个系列的博客要等着更新,几本 ...

  2. 知名IT公司的年度大会合集

    很多知名的IT公司都有年度大会,比如说谷歌,微软,Adobe,甲骨文,苹果等等.在这些公司的年度大会上,都会展示一些公司比较前沿的产品.看看这些大会的视频(也可以参会,但是门票可是非常贵的),对我们了 ...

  3. Linux用户管理命令(第二版)

    添加用户 1.useradd -设置选项 用户名 [-D 查看缺省参数 ] 选项: u: UID [必须是系统中没有的] g:缺省所属用户组GID[最好有] G: 指定用户所属多个组[可以指定这个用户 ...

  4. 理解WebKit和Chromium: Chromium的多进程资源加载机制

    转载请注明原文地址:http://blog.csdn.net/milado_nju ##概述 前面介绍了WebKit中的资源加载机制,其实它只是一个框架性的东西,实际的资源加载依赖于各个WebKit移 ...

  5. 如何手动实现C语言中的字符串操作

    学了字符串操作,很多人也许学了大概知道怎么用,但是太久没用就忘了,恰恰这是找软件工程师或者嵌入式工程师以及C,C++相关的笔试面试必考的题目!接下来我们来看看如何手动实现这些相关的函数. 废话不多说, ...

  6. OpenCV 矩形轮廓检测

    转载请注明出处:http://blog.csdn.net/wangyaninglm/article/details/44151213, 来自:shiter编写程序的艺术 基础介绍 OpenCV里提取目 ...

  7. Xcode自定义字体不能应用的原因

    想给UILabel换一个自定义的字体,从字体册选择兰亭黑: 然后选择 在Finder中显示,找到字体文件为Lantinghei.ttc: 将其拷贝到项目中,在info.plist里添加字体支持key, ...

  8. Android监听自身卸载,弹出用户反馈调查

    1,情景分析 在上上篇博客中我写了一下NDK开发实践项目,使用开源的LAME库转码MP3,作为前面几篇基础博客的加深理解使用的,但是这样的项目用处不大,除了练练NDK功底.这篇博客,我将讲述一下一个各 ...

  9. 网站系统压力测试Jmeter+Badboy

    最近项目需要压力测试,因此搜了几款试用,首选的是LoadRunner这款大名鼎鼎的测试软件: LoadRunner11 下载请猛戳这里 传送门LoadRunner破解文件 下载请猛戳这里 传送门Loa ...

  10. Ajax+jquery+jaso传输数据

    所谓的Ajax.这里我们讲二种方法  方法一:(微软有自带Ajax框架)  在Asp.net里微软有自己的Ajax框架.就是在页面后台.cs文件里引入 using System.Web.Service ...