当前位置:网站首页>1015 theory of virtue and talent
1015 theory of virtue and talent
2022-06-29 04:11:00 【Lele ~ll】
Sima Guang, a historian of the Song Dynasty 《 History As A Mirror 》 There is a famous passage in “ On virtue and talent ”:“ That's why we call it a saint , It's a fool to have both talent and morality , Virtue is a gentleman , Cai Shengde is called villain . The art of taking people , Not a saint , It's a gentleman , It's better to be a villain , If you don't get a fool .”
Here are the scores of a group of candidates , Please give the admission ranking according to Sima Guang's theory .
Input format :
The first line of input is given 3 A positive integer , Respectively :N(≤105), That is, the total number of candidates ;L(≥60), For the lowest score , That is, both moral and talent scores are no less than L Candidates are eligible to be considered for Admission ;H(<100), For the priority admission line —— Those whose moral and talent scores are not lower than this line are defined as “ Just do everything ”, Such candidates are ranked from high to low according to the total score of virtue and talent ; The candidates who can't get the grade but get the priority admission line belong to “ Deshengcai ”, Also sort by total score , But after the first category of candidates ; Both moral and talent scores are lower than H, But candidates with a moral score of no less than talent belong to “ Both talent and morality ” But there is still “ Deshengcai ” person , Sort by total score , But after the second category of candidates ; Others reach the lowest line L The candidates are also ranked according to the total score , But after the third category of candidates .
And then N That's ok , Each line gives the information of one candidate , Include : Ticket number Defen Talent , among Ticket number by 8 An integer , Virtue and talent are divided into intervals [0, 100] The whole number inside . Numbers are separated by spaces .
Output format :
The first line of the output first gives the number of candidates who have reached the lowest score line M, And then M That's ok , Each line outputs the information of one candidate according to the input format , Candidates are sorted from high to low according to the rules described in the input . When there are more than one examinee in a certain category, they always share the same score , In descending order of virtue ; If the German points are also tied , Then it will be output in ascending order of the admission certificate number .
sample input :
14 60 80
10000001 64 90
10000002 90 60
10000011 85 80
10000003 85 80
10000004 80 85
10000005 82 77
10000006 83 76
10000007 90 78
10000008 75 79
10000009 59 90
10000010 88 45
10000012 80 100
10000013 90 99
10000014 66 60
sample output :
12
10000013 90 99
10000012 80 100
10000003 85 80
10000011 85 80
10000004 80 85
10000007 90 78
10000006 83 76
10000005 82 77
10000002 90 60
10000014 66 60
10000008 75 79
10000001 64 90The code is as follows :
#include<stdio.h>
typedef struct {
int id;
int de;// Virtue
int cai;// only
int sum;
}STU;
void prin(STU a[100000], int n)
{
int i, j;
// int k = n - 1;
for (i = 0; i < n - 1; i++)
{
int flag = 0;
for (j = 0; j < n-i-1; j++)
{
if (a[j].sum < a[j + 1].sum)
{
STU f = a[j];
a[j] = a[j + 1];
a[j + 1] = f;
flag = 1;
}
else if (a[j].sum == a[j + 1].sum && a[j].de < a[j + 1].de)
{
STU f = a[j];
a[j] = a[j + 1];
a[j + 1] = f;
flag = 1;
}
else if (a[j].sum == a[j + 1].sum && a[j].de == a[j + 1].de&&a[j].id>a[j+1].id)
{
STU f = a[j];
a[j] = a[j + 1];
a[j + 1] = f;
flag = 1;
}
//k = pos;
}
if (flag == 0)
{
break;
}
}
for (i = 0; i < n; i++)
{
printf("%d %d %d\n", a[i].id, a[i].de, a[i].cai);
}
}
int main()
{
int num, min, good;// Number of candidates , Minimum admission line , Priority admission line
int i, j, k;// Service for circulation
int number = 0;
int id, de, cai;
STU a[10000]; int an = 0;//de>good && cai >good
STU b[10000]; int bn = 0;//de>=good && cai<good
STU c[10000]; int cn = 0;//de>=min &&cai >=min &&de>=cai
STU d[10000]; int dn = 0;//de>=min&&cai>=min
scanf("%d %d %d", &num, &min, &good);
for (i = 0; i < num; i++)
{
scanf("%d %d %d", &id, &de, &cai);
if (de >= good && cai >= good)
{
a[an].id = id; a[an].de = de; a[an].cai = cai;
a[an].sum = de + cai;
an++; number++;
}
else if (de >= good && cai < good && cai >= min)
{
b[bn].id = id; b[bn].de = de; b[bn].cai = cai;
b[bn].sum = de + cai;
bn++; number++;
}
else if (de >= min && cai >= min && de >= cai)
{
c[cn].id = id; c[cn].de = de; c[cn].cai = cai;
c[cn].sum = de+cai;
cn++; number++;
}
else if (de >= min && cai >= min)
{
d[dn].id = id; d[dn].de = de; d[dn].cai = cai;
d[dn].sum = de + cai;
dn++; number++;
}
}
printf("%d\n", number);
prin(a, an);
prin(b, bn);
prin(c, cn);
prin(d, dn);
return 0;
}
边栏推荐
猜你喜欢

Mécanisme d'attention du canal de fixation

Cloud native weekly | grafana 9 was officially released; The Chinese version of cloud native vocabulary is now online

Remote connection of raspberry pie in VNC Viewer Mode

How sqlserver queries and removes results with null fields in the whole column

科班出身,结果外包都不要

Inftnews | metauniverse technology will bring a new shopping experience

How to back up all data on Apple mobile phone in 2 steps (free)

干货丨微服务架构是什么?有哪些优点和不足?

Yangzhou needs one English IT Helpdesk Engineer -20220216

基于xlsx的B+树索引实现
随机推荐
增额终身寿险下架了吗?现在还有哪些增额终身寿险产品?
Emotional changes need to be controlled
Ansible best practices playbook different context rights raising demo
Technology: how to design zkvm circuit
The second meeting of the Second Council of Euler open source community was held, and Xinhua III, hyperfusion and Godson Zhongke became members of the Council
多机局域网办公神器 rustdesk 使用强推!!!
Establishment of small and medium-sized enterprise network
自己动手搭建一个简单的网站
Ask the handler about the memory leak scenario in the interview. Don't just know static internal classes & weak references!
JSX的基本使用
【Laravel系列8】走出 Laravel 的世界
Canoe- how to parse messages and display information in the trace window (use of program node and structure type system variables)
科技雲報道:混合辦公的B面:安全與效率如何兼得?
请问大佬,Oracle CDC报错 Call snapshotState on closed sou
How to merge upstream and downstream SQL data records
Rapid development project -vscode plug-in
【FPGA+sin】基于DDS(直接数字合成)的正弦信号发生器模块FPGA实现
Call snapstateon closed sou from Oracle CDC
SqlServer如何查询除去整列字段为null的结果
If I hadn't talked to Ali P7, I wouldn't know I was a mallet