Rank List

Rank List

Li Ming is a good student. He always asks the teacher about his rank in his class after every exam, which makes the teacher very tired. So the teacher gives him the scores of all the student in his class and asked him to get his rank by himself. However, he has so many classmates, and he can’t know his rank easily. So he tends to you for help, can you help him?
Input
The first line of the input contains an integer N (1 <= N <= 10000), which represents the number of student in Li Ming’s class. Then come N lines. Each line contains a name, which has no more than 30 letters. These names represent all the students in Li Ming’s class and you can assume that the names are different from each other.

In (N+2)-th line, you’ll get an integer M (1 <= M <= 50), which represents the number of exams. The following M parts each represent an exam. Each exam has N lines. In each line, there is a positive integer S, which is no more then 100, and a name P, which must occur in the name list described above. It means that in this exam student P gains S scores. It’s confirmed that all the names in the name list will appear in an exam.
Output
The output contains M lines. In the i-th line, you should give the rank of Li Ming after the i-th exam. The rank is decided by the total scores. If Li Ming has the same score with others, he will always in front of others in the rank list.

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
map<string,int>x;
int main() {
	int n,j,k,l,m,i,sum;
	char s[10100][50],a[10010],b[100];
	scanf("%d\n",&n);
	for(i=0; i<n; i++) {
		gets(s[i]);
		x[s[i]]=0;
	}
	scanf("%d\n",&m);
	while(m--) {
		for(i=0; i<n; i++) {
			scanf("%d ",&sum);
			gets(b);
			x[b]+=sum;
		}
		int l=x["Li Ming"],c=1;
		for(i=0;i<n;i++){
			if(x[s[i]]>l)
			c++;
		}
		printf("%d\n",c);
	}

}
#include<iostream>
#include<map>
using namespace std;
map<string,string>x; 
string s;
string aa[25];
int main() {
	x["asd"]="zxc";
	x["zxc"]="asd";
	cin>>s;
	cout<<x[s];
	
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ACM/ICPC比赛成绩会按照一定的规则计算各位参赛者的名次并实时显示排行榜,计算规则主要参考解题的数量及罚时,解题数量越多,罚时越少,则排名越高。 解题数量很容易计算,只需考察比赛中标记为“Accepted”的题数即可。罚时计算则相对复杂,对于提交到竞赛系统中的每道题目,系统会给出一个罚时,为从比赛开始到该题提交的代码第一次被“Accepted”的时间。请注意,只是第一次“Accepted”。对于“Accepted”之前的每次提交,都有20分钟的罚时,但如果该题目最终未解出,则不计罚时。 先在有一个比赛的题目通过情况记录,请生成该比赛的排行榜。 示例输入: 2008-04-25 18:00:00 2008-04-25 23:30:00 1000 1001 1002 1003 1004 38 602203621 1002 Accepted 756K 30MS C++ 2008-04-25 18:04:59 37 liheyuan 1002 Wrong_Answer 768K 10MS C++ 2008-04-25 18:28:05 36 ftest 1000 Accepted 888K 10MS C++ 2008-04-25 21:30:32 35 ftest 1000 Accepted 904K 10MS C++ 2008-04-25 21:30:55 34 gaojianwei 1000 Accepted 768K 10MS C 2008-04-25 22:15:58 33 gaojianwei 1001 Wrong_Answer 904K 10MS C 2008-04-25 22:18:01 32 gaojianwei 1004 Accepted 768K 10MS C 2008-04-25 22:24:23 31 lzz 1000 Accepted 904K 10MS C++ 2008-04-25 23:29:27 30 lzz 1001 Wrong_Answer 904K 10MS C++ 2008-04-25 23:30:17 示例输出: Rank Name Solved 1000 1001 1002 1003 1004 Penalty 1 gaojianwei 2 4:15:58 -1 0 0 4:24:23 8:40:21 2 602203621 1 0 0 0:04:59 0 0 0:04:59 3 ftest 1 3:30:32 0 0 0 0 3:30:32 4 lzz 1 5:29:27 0 0 0 0 5:29:27 5 liheyuan 0 0 0 -1 0 0 0:00:00
在Python中,rank函数用于计算数值数据的排名。通过该函数可以将一组数值按照大小进行排名,并返回每个数值的排名值。rank函数可以应用于Series对象和DataFrame对象。 对于Series对象,rank函数的语法如下: Series.rank(axis=0,method='average',numeric_only=None,na_option='keep',ascending=True,pct=False) 其中,参数axis表示排名的轴,默认为0,即按列进行排名;参数method表示破坏平级关系的方式,默认为'average',即分配平均排名;参数numeric_only表示是否仅针对数值进行排名,默认为None,即对所有数据进行排名;参数na_option表示对缺失值的处理方式,默认为'keep',即保留缺失值;参数ascending表示排名是否按升序排列,默认为True,即升序排列;参数pct表示是否返回相对于总数的百分比排名,默认为False,即返回绝对排名。 对于DataFrame对象,rank函数的语法如下: DataFrame.rank(axis=0, method='average', numeric_only=NoDefault.no_default, na_option='keep', ascending=True, pct=False) 其中,参数axis表示排名的轴,默认为0,即按列进行排名;其他参数的含义与Series的rank函数相同。 因此,Python中的rank函数可以用于计算数值数据的排名,并根据指定的参数进行破坏平级关系的操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Python函数:rank()](https://blog.csdn.net/Ajdidfj/article/details/123136959)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [python pandas rank()详解](https://blog.csdn.net/m0_37813354/article/details/103068573)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值