1137 Final Grading (25 point(s))

PAT甲级1137 Final Grading (25分) 测试点3过不去的问题,AC代码+注释 点击进入源题 题目大意:对给出的若干考生的上机考试,期中考试,期末考试成绩进行汇总,按照一定顺序输出及格的学生。 注意点:1.及格的条件为上机考试分数不低于200分,同时总成绩不低于六十,注意,是总成绩,不是期末成绩,这 里弄错的话测试点3过不去。 2.如果使用map来实现考生名字与期中成绩的映射的话,有可能会把0分考生误认为缺考,毕竟访问不存 在的Key时默认的初值就是0;这里出错测试点3也过不去; 3.总成绩用整型,取整的方式时rounded up 要记得四舍五入 阅读详情

1137 Final Grading (25 point(s))

For a student taking the online course "Data Structures" on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first obtain no less than 200 points from the online programming assignments, and then receive a final grade no less than 60 out of 100. The final grade is calculated by G=(G​mid−term​​×40%+G​final​​×60%) if G​mid−term​​>G​final​​, or G​final​​ will be taken as the final grade G. Here G​mid−term​​ and G​final​​ are the student's scores of the mid-term and the final exams, respectively.

The problem is that different exams have different grading sheets. Your job is to write a program to merge all the grading sheets into one.

Input Specification:

Each input file contains one test case. For each case, the first line gives three positive integers: P , the number of students having done the online programming assignments; M, the number of students on the mid-term list; and N, the number of students on the final exam list. All the numbers are no more than 10,000.

Then three blocks follow. The first block contains P online programming scores G​p​​'s; the second one contains M mid-term scores G​mid−term​​'s; and the last one contains N final exam scores G​final​​'s. Each score occupies a line with the format: StudentID Score, where StudentID is a string of no more than 20 English letters and digits, and Score is a nonnegative integer (the maximum score of the online programming is 900, and that of the mid-term and final exams is 100).

Output Specification:

For each case, print the list of students who are qualified for certificates. Each student occupies a line with the format:

StudentID G​p​​ G​mid−term​​ G​final​​ G

If some score does not exist, output "−1" instead. The output must be sorted in descending order of their final grades (G must be rounded up to an integer). If there is a tie, output in ascending order of their StudentID's. It is guaranteed that the StudentID's are all distinct, and there is at least one qullified student.

Sample Input:

6 6 7
01234 880
a1903 199
ydjh2 200
wehu8 300
dx86w 220
missing 400
ydhfu77 99
wehu8 55
ydjh2 98
dx86w 88
a1903 86
01234 39
ydhfu77 88
a1903 66
01234 58
wehu8 84
ydjh2 82
missing 99
dx86w 81

Sample Output:

missing 400 -1 99 99
ydjh2 200 98 82 88
dx86w 220 88 81 84
wehu8 300 55 84 84

排序、STL(unordered_map、vector)。

写完这个题,真的想打自己两耳光。认真读题真的不是一句开玩笑的话!这里是说在线成绩大于200分且总评成绩大于60分才可以获得证书,而不是期末卷面成绩要大于60分!注意final grade和final exam grade!做的时候还在想ZJU期末卷面及格才可以真正及格很严厉,哈哈原来也不是的。

注意点:

1. 最开始是思路是存储在数组里,然后建立姓名到编号(自定义)的映射,然后下标对于编号的数组元素存储结构体。实际上可以直接建立map<string,grade> mp的映射,然后采取pair的方式或者再把map的key存储到value中,然后提取到线性结构vector中排序;

2. 注意C++11 auto的使用,极大减少代码量;

3. 取整函数round(),也可直接加0.5。

代码1:

#include<iostream>
#include<cstring>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<cmath>
using namespace std;
struct grade{
	string id;int online=-1,mid=-1,final=-1;int total=0;
	void calculator(){
		if(mid>final) total=(int)(0.5+mid*0.4+final*0.6);
		else total=final;
	}
};
bool cmp(grade a,grade b){
	if(a.total!=b.total) return a.total>b.total;
	else return a.id<b.id;
}
unordered_map<string,grade> mp; 
vector<grade> v;
int P,M,N;
int main(void){
	cin>>P>>M>>N;//ONLINE MID FINAL
	string s;int n;
	for(int i=0;i<P;i++){
		cin>>s>>n;
		if(n<=900) mp[s].online = n;
	}
	for(int i=0;i<M;i++){
		cin>>s>>n;
		if(n<=100) mp[s].mid = n;
	}
	for(int i=0;i<N;i++){
		cin>>s>>n;
		if(n<=100) mp[s].final = n;
	}
	for(auto it:mp){
		if((it.second).online>=200){
			(it.second).calculator();
			if((it.second).total>=60){
				(it.second).id = it.first;
				v.push_back(it.second);
			}
			
		}
	}
	sort(v.begin(),v.end(),cmp);
	for(int i=0;i<v.size();i++){
		cout<<v[i].id<<" "<<v[i].online<<" "<<v[i].mid<<" "<<v[i].final<<" "<<v[i].total<<endl;
	} 
	return 0; 
}

代码2: 

#include<iostream>
#include<cstring>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<cmath>
using namespace std;
const int MAX = 3e4+7;
struct grade{
	string id;int online=-1,mid=-1,final=-1;int total=0;
	void calculator(){
		if(mid>final) total=(int)round(0.40*(double)mid+0.60*(double)final);
		else total=final;
	}
	bool operator < (const grade &other) const{
		if(total!=other.total) return total>other.total;
		return id<other.id;
	}
};
unordered_map<string,int> mp;//name-index 
grade G[MAX];
vector<grade> v;
int main(void){
	int P,M,N;cin>>P>>M>>N;//ONLINE MID FINAL
	int index = 0;string s;int n;
	mp.clear();
	for(int i=0;i<P;i++){
		cin>>s>>n;
		if(mp.find(s)!=mp.end()){
			G[mp[s]].online=n;
		}else{
			mp.insert({s,index});
			index++;
			G[mp[s]].online=n;
			G[mp[s]].id=s;
		}
	}
	for(int i=0;i<M;i++){
		cin>>s>>n;
		if(mp.find(s)!=mp.end()){
			G[mp[s]].mid=n;
		}else{
			mp.insert({s,index});
			index++;
			G[mp[s]].mid=n;
			G[mp[s]].id=s;
		}
	}
	for(int i=0;i<N;i++){
		cin>>s>>n;
		if(mp.find(s)!=mp.end()){
			G[mp[s]].final=n;
		}else{
			mp.insert({s,index});
			index++;
			G[mp[s]].final=n;
			G[mp[s]].id=s;
		}
	}
	for(int i=0;i<index;i++){
		G[i].calculator();
		if(G[i].online>=200&&G[i].total>=60){
			v.push_back(G[i]);
		}
	}
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++) cout<<v[i].id<<" "<<v[i].online<<" "<<v[i].mid<<" "<<v[i].final<<" "<<v[i].total<<endl;
	return 0; 
}

 

C#安装OpenCv及打开笔记本默认摄像头方法 阅读详情

相关推荐

别再瞎调参数了!分子动力学模拟新手必看的力场选择与验证实战指南

本文为分子动力学模拟新手提供力场选择与验证的实战指南,详细解析主流力场特性及适用场景,并通过水分子案例演示完整的验证流程。文章重点对比SPC/E、TIP3P和OPLS-AA三种力场在GROMACS中的表现,帮助读者避免常见参数调整误区,提升模拟准确性。

weixin_26934905的博客 426

1137. Final Grading 解析

要注意主要是取百分比的时候需要进位。按四舍五入的规则就好。 #include #include #include #include #include #include #include #include #include #include #define MAX 10010 using namespace std; int p,m,n; struct node{ s

sheepyWYY的博客 800

Multisim 14.0实战:从零搭建可调幅多波形信号发生器(附仿真文件)

本文详细介绍了如何在Multisim 14.0中从零搭建一个可调幅多波形信号发生器,涵盖方波、三角波和正弦波的生成原理与实现步骤。通过核心电路架构解析、关键参数设计及Multisim实战操作,帮助电子工程学习者和硬件工程师掌握信号发生器的设计与调试技巧,并提供仿真文件供实践验证。

nokia的博客 1073

1137 Final Grading (25point(s))(解题记录)

Define a struct stu ,store students’ information in a stu array(I use a map to find the student’s index in array according to their ID),and then sort the array based on the rules given in question.Last,print the list of students who are qualified for certi

momoomoo的博客 223

大模型技术全景与核心概念解析:从基础原理到AI智能体架构(实时更新中)

本文系统解析了大模型技术的核心概念与架构。首先介绍了LLM(大语言模型)、LLMOps(模型运维)、AIGC(生成内容)、AGI(通用AI)等基础概念,重点阐述了大模型的工作原理,包括预处理、推理和后处理三个阶段。深入讲解了Token分词、FLOPs计算、Embedding向量表示等关键技术,并分析了LoRA微调、MoE架构等前沿方法。文章还探讨了AI智能体的发展前景,为理解大模型技术提供了全景视角。

算法工程师 1250

【第07例】IPD体系进阶: 6 个技术评审点(TR)

TR技术评审点

产品线负责人 4421

1137 Final Grading (25 point(s))

题解 STL应用。 #include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;cmath&gt; #include&lt;algorithm&gt; #include&lt;map&gt; using namespace std; const int MAXN = 1e4 + 10; struct node { string...

徐伯莱 250

MATLAB使用贝叶斯网络bnt工具箱:使用手册详解

MATLAB使用贝叶斯bnt网络工具箱:使用手册详解

WW、forever的博客 2676

PAT_甲级_1137 Final Grading (25point(s)) (C++)【模拟/成绩排序】

目录 1,题目描述 题目大意 注意 2,思路 3,AC代码 4,解题过程 第一搏 第二搏 1,题目描述 Sample Input: 6 6 7 01234 880 a1903 199 ydjh2 200 wehu8 300 dx86w 220 missing 400 ydhfu77 99 wehu8 55 ydjh2 98 dx86w 88 a1903 86 01234...

&再见萤火虫&的博客 266

第17章 后端开发最佳实践 —— OpenSpec + 智能体的工程化实战

后端开发有大量重复性的"样板代码"工作。我们可以创建自定义 Skill,让 AI 自动生成标准的三层架构代码。创建 Skill:后端 CRUD 生成器以 CodeBuddy 为例,在创建:其他工具用户请参考各自文档,了解如何创建自定义 Skills 或类似机制。skill.md## 描述根据实体定义自动生成标准的三层架构代码(Controller-Service-Repository)## 适用场景- 快速创建实体的 CRUD 接口- 保持代码结构一致性- 减少重复性编码工作## 使用方法。

快乐的修补匠的专栏 322

智能车图像处理0-图像处理整体框架思路

1.总体框架如上所示,具体代码请查看后续文章。2.因为参与竞赛时间是大二,所以在编程中有许多不规范的地方(如变量的命名),大家见谅。3.原创文章,请勿侵权=-=

taiyuezyh的博客 1万+

1137 Final Grading (25point(s)) - C语言 PAT 甲级

* 似乎又是一道排序题,处理好排序即可

有三只土豆 214

Open3D 计算点云的倒角距离(Chamfer Distance)【2025最新版】

;Chamfer Distance距离可以计算生成点云数据与标签点云数据之间的平均最短点距离。Open3D可以直接用来计算点云的Chamfer Distance距离。博客长期更新,本文最近一次更新时间为:2025年2月18日。

点云侠的博客 3254

【PAT】A1137 Final Grading (25point(s))

文章目录A1137 Final Grading (25point(s))Input Specification:Output Specification:Sample Input:Sample Output:CodeAnalysis Author: CHEN, Yue Organization: 浙江大学 Time Limit: 200 ms Memory Limit: 64 MB Code Si...

Duke 274

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

1137 Final Grading (25 point(s))

For a student taking the online course "Data Structures" on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first obtain no less than 200 points from...

张蔡辉 251

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

PTA(A)1137 Final Grading (25point(s))(模拟)

思路: 模拟即可。 代码: #include <bits/stdc++.h> #include <cstdio> using namespace std; struct node { string name; int gp = -1; int gmid = -1; int gfinal = -1; int g = -1; }; set<string>peo_name; map<string, node>peo_d.

Sqssq的博客 231

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

PAT(A) 1137 Final Grading (25 point(s))

审题啊呜呜呜!final grade和Gfinal不是同一个东西!!!大哭.gif #include<bits/stdc++.h> using namespace std; struct node{ string id; int Gp, Gmid, Gfinal, G; }; bool cmp(node a, node b){ if(a.G == b.G) return a.id < b.id; return a.G > b.G;

Anpotan的博客 121

1137. Final Grading (25)-PAT甲级真题

1137. Final Grading (25) For a student taking the online course "Data Structures" on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first obtain no

柳婼 の blog 2317

1137 Final Grading (25分) 测试点4答案错误的看过来~

1137 Final Grading (25分) For a student taking the online course “Data Structures” on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first obtain no ...

weixin_43957537的博客 1041

PAT甲级 1137. Final Grading (25)

For a student taking the online course "Data Structures" on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first obtain no less than 200 points from...

moffy_abo的博客 439

PAT甲级 1137 Final Grading (25 分)

1137 Final Grading (25 分) 题目 For a student taking the online course “Data Structures” on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first obtain...

小熊猫的博客 483

1137. Final Grading (25)[结构体排序]

1. 原题: https://www.patest.cn/contests/pat-a-practise/1137 2. 思路 题意:结构体排序 给出学生成绩,输出符合要求的成绩即可。 用到了map容器。 注意:题目中要求最终成绩>=60, 不是final(期末成绩)。 我在这里卡了很久(最后一个测试点)。 已AC。 3. 源码 #include #include #incl

坚不萌 328

PAT 甲级 1137  Final Grading

1137Final Grading(25 point(s)) For a student taking the online course "Data Structures" on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first o...

漫浸天空的雨色的备忘录~ 978

[C++] PAT 1137 Final Grading (25分)

Sample Input: 6 6 7 01234 880 a1903 199 ydjh2 200 wehu8 300 dx86w 220 missing 400 ydhfu77 99 wehu8 55 ydjh2 98 dx86w 88 a1903 86 01234 39 ydhfu77 88 a1903 66 01234 58 wehu8 84 ydjh2 82 missing 99 dx86w 81 Sample Output: missing 400 -1 99 99 ydjh2 200 9.

快乐de约定的博客 1973

PAT 1137 Final Grading

原文链接:我的个人博客 原题链接   PAT 1137 Final Grading 考点   结构体;排序 思路   函数sti,用于将学生姓名与自定义的id号进行对应。根据题目输入,初始化任务点、平时分和期末分。最后根据合格的要求(任务点不少于200,最后得分在60-100),将符合要求的学生push_back进入ans中。再根据题目要求,自定义排序规则。最后输出即可。 代码 ...

我是没有梦想的小白 161

1137 Final Grading

题目大意: 每个学生有四个成绩,线上成绩,期中,期末,总分。现在分别给出这四门成绩下对应的学生分数情况。要求按照总分从大到小(分数相同则按照ID字典序升序)输出总分及格(&gt;=60分)的学生成绩情况。线上成绩必须不小于200分。 解题思路: 用MAP给每名学生分配唯一的编号方便用结构体保存信息并排序,输入时对于线上成绩小于200的学生不保存。 代码如下: #include&lt;iostre...

Apollo的博客 489
上一篇: 1132 Cut Integer (20 point(s))
下一篇: 1138 Postorder Traversal (25 point(s))
coderwait
博客等级 码龄9年 20粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值