ZJU PAT 1012 The Best Rank

ZJU-PAT 1078. Hashing (25) 浙大2014年上机复试第二题 #include #include #include #include #include using namespace std; const int MaxN=20001; int n,m; bool Position[MaxN]; void special_process(int cur) { for(int i=1; i<m; i++) { int po 阅读详情
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;

#define Min(a,b)(a<b?a:b)

int n,m;
struct student
{
	int id,ctest,math,english;
	double avg;
	int crank,mrank,erank,arank;
	int bestrank;
	string bsetrankname;
};
student TT[2005];

bool cmpa(student a,student b)
{
	return a.avg>b.avg;
}

bool cmpc(student a,student b)
{
	return a.ctest>b.ctest;
}

bool cmpm(student a,student b)
{
	return a.math>b.math;
}

bool cmpe(student a,student b)
{
	return a.english>b.english;
}

void MakeaRank()
{
	for(int i=0;i<n;i++)
	{
		if(i==0) 
		{
			TT[i].arank=1;
			continue;
		}
		
		if(TT[i].avg!=TT[i-1].avg)
		{
			TT[i].arank=i+1;
		}
		else
		{
			TT[i].arank=TT[i-1].arank;
		}
	}
}

void MakecRank()
{
	for(int i=0;i<n;i++)
	{
		if(i==0) 
		{
			TT[i].crank=1;
			continue;
		}
		
		if(TT[i].ctest!=TT[i-1].ctest)
		{
			TT[i].crank=i+1;
		}
		else
		{
			TT[i].crank=TT[i-1].crank;
		}
	}
}

void MakemRank()
{
	for(int i=0;i<n;i++)
	{
		if(i==0) 
		{
			TT[i].mrank=1;
			continue;
		}
		
		if(TT[i].math!=TT[i-1].math)
		{
			TT[i].mrank=i+1;
		}
		else
		{
			TT[i].mrank=TT[i-1].mrank;
		}
	}
}

void MakeeRank()
{
	for(int i=0;i<n;i++)
	{
		if(i==0) 
		{
			TT[i].erank=1;
			continue;
		}
		
		if(TT[i].english!=TT[i-1].english)
		{
			TT[i].erank=i+1;
		}
		else
		{
			TT[i].erank=TT[i-1].erank;
		}
	}
}

void MakeBest()
{
	for(int i=0;i<n;i++)
	{
		int tmp=TT[i].arank;
		string ss="A";
		
		if(TT[i].crank<tmp)
		{
			tmp=TT[i].crank;
			ss="C";
		}
		if(TT[i].mrank<tmp)
		{
			tmp=TT[i].mrank;
			ss="M";
		}
		if(TT[i].erank<tmp)
		{
			tmp=TT[i].erank;
			ss="E";
		}
		TT[i].bestrank=tmp;
		TT[i].bsetrankname=ss;
	}
}

void run()
{
	int i,j;
	
	for(i=0;i<n;i++) 
	{
		scanf("%d%d%d%d",&TT[i].id,&TT[i].ctest,&TT[i].math,&TT[i].english);
		TT[i].avg=(TT[i].ctest+TT[i].math+TT[i].english)*1.0/3.0;
	}

	//----cmp by avg-----------
	sort(TT,TT+n,cmpa);
	MakeaRank();
	
	//----cmp by ctest-----------
	sort(TT,TT+n,cmpc);
	MakecRank();
	
	
	//----cmp by math------------
	sort(TT,TT+n,cmpm);
	MakemRank();
	
	//----cmp by english------------
	sort(TT,TT+n,cmpe);
	MakeeRank();
	
	//----cmp by math------------
	sort(TT,TT+n,cmpa);
	MakeaRank();
	
	MakeBest();
	
	
	int curid;
	for(i=0;i<m;i++)
	{
		scanf("%d",&curid);
		for(j=0;j<n;j++)
		{
			if(TT[j].id==curid)
			{
				printf("%d %s\n",TT[j].bestrank,TT[j].bsetrankname.c_str());
				break;
			}
		}
		if(j==n)
			printf("N/A\n");
	}
}

int main()
{
	while(scanf("%d%d",&n,&m)!=EOF) run();
	return 0;
}

给出学生3门课的成绩,求每名学生在3门课以及平均分中所能取得的最高排名。

注意:并列排名的处理上:应该是1 2 3 3 5,而不是1 2 3 3 4


电流互感器的使用分析 有关电流互感器使用的注意事项,回头再看,耳目一新。 阅读详情

相关推荐

RV1126B SDK移植实战:从DDR配置到USB烧写全解析

本文详细解析了RV1126B SDK移植的核心实战流程,重点攻克了DDR初始化失败与USB烧写两大难题。文章从理解启动流程入手,提供了DDR配置错误的排查步骤、SDK编译配置要点,并深入讲解了USB烧写的完整操作与常见问题解决方案,旨在帮助开发者高效完成系统移植与稳定运行。

weixin_29164497的博客 542

浙江大学PAT上机题解析之1012. 数字分类 (20)

1012. 数字分类 (20) 时间限制 50 ms 内存限制 32000 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 给定一系列正整数,请按要求对数字进行分类,并输出以下5个数字: A1 = 能被5整除的数字中所...

weixin_30813225的博客 855

centos7下安装gcc-10.3.0

生成多个系统版本的代码,如果你的操作系统是32位,默认就已经设置为 disable,这时gcc仅能生成32位的可执行程序;这里只开启了c,c++ 和fortran,因为支持的语言越多,就需要安装越多的相应静态与动态库,还有五花八门的依赖库,这会让管理变得困难,体积也会变得庞大。启用posix标准的线程支持,这个设置取决于宿主或目标操作系统的类型,其它可用值有:aix,dec,solaris,win32等,如果你是其它的类UNIX系统,就需要设置相应的值。指定安装路径,这里没有指定,就直接放到文件夹里就好。

lxystar2003的博客 1189

ZJU PAT 1012 The Best Rank

给出学生3门课的成绩,求每名学生在3门课以及平均分中所能取得的最高排名。 这是一道极水的题目,却提交了n次才过,一开始以为是平均分求法的问题,后来才发现关键在于并列排名的处理上:应该是1 2 3 3 5,而不是1 2 3 3 4 1 from operator import itemgetter 2 n, m = raw_input().split() 3 dictC = {} ...

weixin_30318645的博客 67

详解ReID的各部分组成及Trick——基于FastReID

这一系列博客将基于京东开源的FastReID进行扩充,详细介绍了ReID的各个组成部分,一些有用的Trick,评价指标,常用数据集等,详细内容见下方的链接,总结不易,如有理解不正确之处,麻烦各位批评指正。 一、FastReID的中的baseline文件配置 二、Training strategy 三、Pre-processing 四、Backbone 五、Aggregation 六、Head 七、Loss 八、Distance Metric 九、Post-processing 十、Evaluation 十一

藏晖的博客 9163

GD32 I2C中断通信实战:主机与从机高效数据交换方案

本文详细解析了GD32微控制器I2C中断通信的实战方案,通过配置I2C0为主机、I2C1为从机,实现高效的双向数据交换。文章深入剖析了中断服务程序(ISR)的核心配置、关键状态标志位处理以及事件驱动机制,帮助开发者避免常见陷阱,提升系统响应速度与资源利用率,适用于传感器连接、多机通信等嵌入式场景。

cream的博客 846

zju pat 1012 The Best Rank

//题意理解错误,理解成每个学生的A,C,M,E成绩中最好的。 //原题意是所有学生的某课成绩排名中最好的排名来算。 #include #include   typedef struct Node{     char name[7];     int grade[3];     int avr;     int best; }Node; /*int getBe

tjusxh的专栏 527

AT32F403A ADC采集实战:如何用V2库精准读取可变电阻电压(附完整代码)

本文详细介绍了基于AT32F403A微控制器和V2库实现高精度ADC采集的工程化方法。内容涵盖从基础的单通道轮询配置到多通道扫描与DMA传输的进阶应用,并重点分享了提升ADC采集精度的关键技巧,包括采样时间优化、软件滤波算法以及硬件布局考量,提供了完整的实战代码,帮助开发者解决数据跳动、稳定性等常见问题。

weixin_29189003的博客 92

1012. The Best Rank

题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1012 // 1. 求平均成绩/3时有精度损失,造成2个测试点错误。不要被例子误导呢 // 2. 调了半小时。题目没说明相同成绩同名次呢! // 3. 函数名要形象,不要用cmp0,cmp1... #include #include #define SIZE 3000+100

Sunshine 709

2024-江苏科技大学-模拟-动态接触角,模拟液滴撞击,comsol软件模拟。

相反,其对液滴粘度和平衡接触角的变化基本不敏感。重力势能的影响显著受过程参数调节,随着液滴直径和密度的增加而增加,而随着初始液滴速度和表面张力系数的增加而减小。通过考虑形状因子和粘度修正因子,可以准确定义表面能和粘性耗散能,使得所提出的半经验修正勺状模型表现出良好的性能,在所有65个研究案例中,液滴最大铺展长度因子(βmax)和中心厚度(h)的相对误差基本分别落在5%和10%的区间内。重力势能的影响受过程参数显著调节,随液滴直径和密度的增大而增大,随液滴初始速度和表面张力系数的增大而减小。

qq_15963745的博客 512

Python爬虫深度对抗:拼多多与得物价格监控系统中的设备指纹模拟与SkyWalking风控绕过实战

在电商数据采集领域,拼多多和得物(毒)APP堪称国产风控系统的“双子星”。前者依托于拼多多集团强大的安全团队,后者则以其独特的“潮流单品”数据价值和高昂的爬取成本闻名。对于任何一名爬虫工程师而言,能够稳定、高效地获取这两大平台的价格、库存、销量等动态信息,都是一项极具挑战性的技术试金石。传统的基于requests库的简单HTTP请求,在面对这两款应用时几乎寸步难行。你会发现,无论怎样伪造User-Agent、怎样轮换代理IP,返回的永远是状态码412403,或者是一个包含验证滑块设备异常的JSON错误。

2201_76125261的博客 865

【PAT】1012. The Best Rank (25)

题目链接: http://pat.zju.edu.cn/contests/pat-a-practise/1012 题目描述: To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programm

此去经年 3061

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

1012. The Best Rank (25)-PAT

1012. The Best Rank (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To evaluate the performance of our first yea

兵临城下 1513

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

精雕软件(JDpaint) 5.5 绿色版

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

PAT 1012. The Best Rank (25)

 To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algebra), and

Steve Sun的专栏 1986

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

PAT(Advanced lecel) 1012. The Best Rank

原题链接:http://pat.zju.edu.cn/contests/pat-a-practise/1012

孤独求败 476

ZJU-PAT 1010. Radix (25)

Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is "yes", if 6 is a decimal number and 110 is a binary number. Now for any pair of positive

Matrix_Reloaded的专栏 4799

ZJU-PAT 1065. A+B and C (64bit) (20)

Given three integers A, B and C in [-263, 263], you are supposed to tell whether A+B > C. Input Specification: The first line of the input gives the positive number of test cases, T ( Output

Matrix_Reloaded的专栏 3966

ZJU-PAT 1080. Graduate Admission (30) 浙大2014年上机复试第四题

#include #include #include #include using namespace std; const int maxn=40005; const int maxm=101; int n,m,k; int num[maxm]; int lastRank[maxm]; vector mm[maxm]; struct stu { int id; int G

Matrix_Reloaded的专栏 2509

ZJU-PAT 1079. Total Sales of Supply Chain (25) 浙大2014年上机复试第三题

#include #include using namespace std; struct Node { int parent; //父节点 bool flag; //是否是retailers int level; //第几层 int num; //销售多少个 }; Node tt[100005]; int n; double p,r,sum;

Matrix_Reloaded的专栏 2205

ZJU-PAT 1057. Stack (30) 浙大2013年上机复试第三题

#pragma warning (disable:4786) #include #include #include #include #include using namespace std; int n,d;; int A[10005],B[10005]; int select(int num) { for(int i=1;i<=d;i++) B[i]=A[i];

Matrix_Reloaded的专栏 1921

ZJU-PAT 1070. Mooncake (25)

Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the region's culture. Now

Matrix_Reloaded的专栏 1892

ZJU-PAT 1081. Rational Sum (20)

模拟题 #pragma warning (disable:4786) #include #include #include #include #include #include #include using namespace std; long long int sum,ans,sum1; int n; struct Node { long long int numerato

Matrix_Reloaded的专栏 1708

ZJU-PAT 1054. The Dominant Color (20) 浙大2013年上机复试第一题

#pragma warning (disable:4786) #include #include #include #include using namespace std; int main() { int m,n; while(scanf("%d%d",&m,&n)!=EOF) { int i,j; string s; map ans;

Matrix_Reloaded的专栏 1612

ZJU-PAT 1077. Kuchiguse (20) 浙大2014年上机复试第一题

#include #include #include #include using namespace std; string longest_common_suffix(string a,string b) { string tmp=""; int len1=a.size()-1; int len2=b.size()-1; while(len1>=0 && len2>=0) {

Matrix_Reloaded的专栏 1413
上一篇: zju-pat 1008.Elevator
下一篇: ZJU PAT 1011. World Cup Betting
Matrix_Reloaded
博客等级 码龄14年 18粉丝 36原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值