PAT_A1083#List Grades
Source:
Description:
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]
andID[i]
are strings of no more than 10 characters with no space,grade[i]
is an integer in [0, 100],grade1
andgrade2
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, outputNONE
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
Keys:
- 模拟题
Attention:
- 先筛选,再排序,可以减少时间复杂度
Code:
/*
Data: 2019-07-13 10:38:02
Problem: PAT_A1083#List Grades
AC: 14:45 题目大意:
按成绩递减打印给定区间内学生的成绩
输入:
第一行给出,人数N
接下来N行,姓名,ID,成绩
最后一行给出,[g1,g2]
输出:
成绩递减,打印姓名和ID
*/
#include<cstdio>
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
const int M=1e3;
using namespace std;
struct node
{
string name,id;
int grade;
}info[M];
vector<node> ans; bool cmp(node a, node b)
{
return a.grade > b.grade;
} int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("Test.txt", "r", stdin);
#endif int n,g1,g2;
scanf("%d", &n);
for(int i=; i<n; i++)
cin >> info[i].name >> info[i].id >> info[i].grade;
scanf("%d%d", &g1,&g2);
for(int i=; i<n; i++)
if(info[i].grade>=g1 && info[i].grade<=g2)
ans.push_back(info[i]);
sort(ans.begin(),ans.end(),cmp);
if(ans.size() == )
printf("NONE\n");
for(int i=; i<ans.size(); i++)
cout << ans[i].name << " " << ans[i].id << endl; return ;
}
PAT_A1083#List Grades的更多相关文章
- PAT1083:List Grades
1083. List Grades (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a l ...
- PAT 甲级 1083 List Grades (25 分)
1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...
- A1083. List Grades
Given a list of N student records with name, ID and grade. You are supposed to sort the records with ...
- Taking water into exams could boost grades 考试带瓶水可以提高成绩?
Takeing a bottle of water into the exam hall could help students boost their grades, researchers cla ...
- PAT 1083 List Grades[简单]
1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...
- PAT 甲级 1083 List Grades
https://pintia.cn/problem-sets/994805342720868352/problems/994805383929905152 Given a list of N stud ...
- PAT 1083 List Grades
#include <cstdio> #include <cstdlib> using namespace std; class Stu { public: ]; ]; }; i ...
- pat1083. List Grades (25)
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 ...
随机推荐
- HTML-参考手册: HTML 语言代码
ylbtech-HTML-参考手册: HTML 语言代码 1.返回顶部 1. HTML 语言代码 参考手册 ISO 语言代码 HTML 的 lang 属性可用于声明网页或部分网页的语言.这对搜索引擎和 ...
- sqlserver定时作业,定时执行存储过程
首先,我想说,我真的是渣了,一个这个玩意弄了半天,算了,直接切入正题吧. 第一步: 先写好存储过程 用了两张表,你们自己建立吧 <br data-filtered="filtered& ...
- processing模拟三角级数合成方波过程
代码 1: int radius = 2; 2: int[] accumys; 3: int times = 0; 4: 5: float scale = 1; 6: int origin = 400 ...
- Django框架(二十二)—— Django rest_framework-频率组件
目录 频率组件 一.作用 二.自定义频率类 三.内置的访问频率控制类 四.全局.局部使用 1.全局使用 2.局部使用 3.局部禁用 五.源码分析 1.as_view -----> view -- ...
- js中继承的实现,原型链的知识点归纳,借用构造函数,组合继承(伪经典继承)
博客搬迁,给你带来的不便,敬请谅解! http://www.suanliutudousi.com/2017/10/31/js%e4%b8%ad%e7%bb%a7%e6%89%bf%e7%9a%84%e ...
- Oracle执行计划不走索引的原因总结
在Oracle数据库操作中,为什么有时一个表的某个字段明明有索引,当观察一些语的执行计划确不走索引呢?如何解决呢?本文我们主要就介绍这部分内容,接下来就让我们一起来了解一下. 不走索引大体有以下几个原 ...
- [轉]User namespaces – available to play!
User namespaces – available to play! Posted on May 10, 2012by s3hh Over the past few months, Eric Bi ...
- A 小G数数
题目链接 题解: 此题可以直接暴力求解,(甚至可以四层循环 具体思想便是a[k]充当两种身份,同时判断两种不同情况,然后计数便可以了 /** /*@author victor /*language c ...
- WPF 动态添加控件以及样式字典的引用(Style introduction)
原文:WPF 动态添加控件以及样式字典的引用(Style introduction) 我们想要达到的结果是,绑定多个Checkbox然后我们还可以获取它是否被选中,其实很简单,我们只要找到那几个关键的 ...
- postgresql 备份数据库结构
--只备份结构pg_dump -U postgres -d grgzpt -f D:\dump.sql -s --备份结构和数据pg_dump -U postgres -d grgzpt -f D:\ ...