【天梯赛】L2-027 名人堂与代金券 (25 point(s))**

穿越隧道

case1和case4,错误于排名,之前的排名i的上限是小于k,导致1,4样例一直过不去。
蒟蒻一枚,被自己菜哭。

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n,g,k;
struct node{
//	char zh[50];
	string zh;
	int idx;
	int score;
}a[N];
int djj;
int cnt2,cnt5;
//bool cmp(node a,node b){
//	if(a.score == b.score){
//		if(strcmp(a.zh,b.zh) > 0) return false;
//		else return true;
		return a.zh < b.zh;
//	} 
//	return a.score > b.score;
//}
bool cmp2(node a,node b){
	if(a.score == b.score) return a.zh < b.zh;
	return a.score > b.score;
//	if(a.score != b.score) return a.score > b.score;
//	 
//	return a.zh < b.zh;
}
int main(){
	cin >> n >> g >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i].zh >> a[i].score;
		if(a[i].score >= g && a[i].score <= 100) cnt5++;
		if(a[i].score >= 60 && a[i].score < g) cnt2++;
	}
	sort(a,a + n,cmp2);
	djj = cnt5*50 + cnt2*20;
	for(int i = 0; i < n; i++){
		a[i].idx = i + 1;
	}
	//case1和case4,错误于排名,之前的排名i的上限是小于k,导致1,4样例一直过不去。 
	for(int i = 1; i < n; i++){
		if(a[i - 1].score == a[i].score){
			a[i].idx = a[i - 1].idx;
		}
	}
//	cout << a[0].score << endl;
//	cout <<"cnt = " << cnt << endl;
//	sort(a,a + n,cmp2);
	cout << djj << endl;
	for(int i = 0;  i < n; i++){
		if(a[i].idx <= k)
			cout << a[i].idx <<" " << a[i].zh <<" " << a[i].score << endl;
	}

	
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值