PAT/1015 德才论c++

#include<bits/stdc++.h>
using namespace std;

struct node{
	int id, d_score, c_score;
};

int m;
vector<node>v1, v2, v3, v4; //才徳全尽,德胜才,才德兼亡, 其他

bool cmp(node x, node y){
	if ((x.d_score+x.c_score) == (y.d_score+y.c_score)){
		if (x.d_score != y.d_score){
			return x.d_score > y.d_score;
		}else{
			return x.id < y.id;	
		}
	}else{
		return (x.d_score+x.c_score) > (y.d_score+y.c_score);
	}	
}

void vprint(vector<node> x){
	for(int i = 0; i < x.size(); i++){
		printf("%d %d %d\n", x[i].id, x[i].d_score, x[i].c_score);
//		cout << x[i].id << x[i].d_score << x[i].c_score << endl;
	}	
	return ;
} 

int main(){
	int n, l, h, a, b, c;
	cin >> n >> l >> h;
	for (int i = 0; i < n; i++){
		cin >> a >> b >> c;
		if (b >= l && c >= l){
			m++;
			if (b >= h && c >= h){
				v1.push_back(node{a, b, c});
			}else if (b >= h && c < h){
				v2.push_back(node{a, b, c});
			}else if (b < h && c < h && b >= c){
				v3.push_back(node{a, b, c});
			}else{
				v4.push_back(node{a, b, c});
			}
		}
	}
	sort(v1.begin(), v1.end(), cmp);
	sort(v2.begin(), v2.end(), cmp);
	sort(v3.begin(), v3.end(), cmp);
	sort(v4.begin(), v4.end(), cmp);
	cout << m << endl;
	vprint(v1);
	vprint(v2);
	vprint(v3);
	vprint(v4);
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值