当前位置:网站首页>1062 talent and virtue (25 points)
1062 talent and virtue (25 points)
2022-06-30 14:55:00 【Xue Dongjing】
1062 Talent and Virtue (25 branch )
The question
Let's start with three numbers N( Number of members ),L( Pass line ),H( Excellent line )
Give a set of member information , Include id, Moral character , can , Sort this group of members .
When the member's moral character and ability are not lower than H, Then the member is divided into excellent group
When the moral character of the member is not lower than H, Can not be lower than L, Then the member is divided into good groups
When the member's moral character and ability are lower than H, But no less than L And virtue is greater than ability , Then the member is divided into the medium group .
Other people are no less virtuous and talented than L, Then they are divided into two groups , Either moral character or ability is inferior to L Will not participate in the ranking .
Priority when ranking Excellent group > Good group > Medium group > Passing group
The higher the total score of morality and ability in the same group , Top of the list . The total score is the same , The higher the moral score, the more advanced . The moral character is the same id The smaller, the more forward .
Ideas
Create a member information structure , contain id, Moral character , can , The total score of morality and talent . Group all members , Sort by rules within the group .
Code
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef struct node{
int id,virtue,talent,total;
}node;
bool cmp(node x,node y)
{
if(x.total==y.total){
if(x.virtue==y.virtue){
return x.id<y.id;
}else{
return x.virtue>y.virtue;
}
}else{
return x.total>y.total;
}
}
node sages[100007],noblemen[100007],fools[100007],others[100007];
int main()
{
// node sages[100007],noblemen[100007],fools[100007],others[100007];
int n,pass,excellent,x,y,z,count1=0,count2=0,count3=0,count4=0;
scanf("%d%d%d",&n,&pass,&excellent);
for(int i=0;i<n;i++){
scanf("%d%d%d",&x,&y,&z);
if(y>=excellent&&z>=excellent){
sages[count1].id=x;
sages[count1].virtue=y;
sages[count1].talent=z;
sages[count1].total=y+z;
count1++;
}else if(y>=excellent&&z>=pass){
noblemen[count2].id=x;
noblemen[count2].virtue=y;
noblemen[count2].talent=z;
noblemen[count2].total=y+z;
count2++;
}else if(y>=z&&z>=pass){
fools[count3].id=x;
fools[count3].virtue=y;
fools[count3].talent=z;
fools[count3].total=y+z;
count3++;
}else if(y>=pass&&z>=pass){
others[count4].id=x;
others[count4].virtue=y;
others[count4].talent=z;
others[count4].total=y+z;
count4++;
}
}
printf("%d\n",count1+count2+count3+count4);
sort(sages,sages+count1,cmp);
for(int i=0;i<count1;i++){
printf("%d %d %d\n",sages[i].id,sages[i].virtue,sages[i].talent);
}
sort(noblemen,noblemen+count2,cmp);
for(int i=0;i<count2;i++){
printf("%d %d %d\n",noblemen[i].id,noblemen[i].virtue,noblemen[i].talent);
}
sort(fools,fools+count3,cmp);
for(int i=0;i<count3;i++){
printf("%d %d %d\n",fools[i].id,fools[i].virtue,fools[i].talent);
}
sort(others,others+count4,cmp);
for(int i=0;i<count4;i++){
printf("%d %d %d\n",others[i].id,others[i].virtue,others[i].talent);
}
return 0;
}
边栏推荐
- 立式加工中心的数控加工对刀具使用基本要求
- CCF access control system (Full Score code + problem solving idea) 201412-1
- Using member variables and member functions of a class
- jsPlumb. Deleteeveryconnection is not a function & jsplumb clear canvas jsplumb delete all nodes and all connections
- 1025 pat ranking (25 points)
- Binary rotation array (2)
- [extensive reading of papers] attributes guided facial image completion
- Analysis on the problems of irregular step hole on horizontal machining center
- Sum of CCF digits (full mark code + problem solving idea) 201512-1
- 1150 traveling salesman problem (25 points)
猜你喜欢

CCF sequence segmentation (Full Score code + problem solving idea) 201509 -1

Computer screenshot how to cut the mouse in

Repair of incorrect deletion of win10 boot entry

CCF string matching (Full Score code + problem solving ideas + skill summary) March 3, 2014

August 24, 2021 deque queue and stack

PS cutting height 1px, Y-axis tiling background image problem

How to get palindrome number in MATLAB (using fliplr function)

Error $(...) size is not a function

DefCamp Capture the Flag (D-CTF) 2021-22 web

ThinkPHP show method parameter controllable command execution
随机推荐
CCF drawing (full mark code + problem solving ideas + skill summary) February 2, 2014
Shift operator (detailed)
CCF string matching (Full Score code + problem solving ideas + skill summary) March 3, 2014
Matlab construction operation example
Location of dichotomy
Win10 backup backup shows that creating a shared protection point on the shadow failed
2021-08-07 native and package types
1134: Legal C identifier query
JS to realize simple lottery function
Shangpinhui knowledge points of large e-commerce projects
【BUUCTF】[GXYCTF2019]Ping Ping Ping1
[extensive reading of papers] multimodal joint attribute prediction and value extraction for e-commerce product
Not satisfied with markdown native code block style? Try this beautify code screenshot tool~~
高清机械原理 · 机械设计经典动图
Matlab function for limit, definite integral, first-order derivative, second-order derivative (classic examples)
Lfi-rce without controllable documents
Learn about data kinship JSON format design from sqlflow JSON format
Add attributes to multimode
The kth largest element in the sorted array
2021-05-12