当前位置:网站首页>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;
}
边栏推荐
- 我的创作纪念日
- 【Laravel系列8】走出 Laravel 的世界
- Data collection and management [10]
- If I hadn't talked to Ali P7, I wouldn't know I was a mallet
- 1018 锤子剪刀布
- 选对学校,专科也能进华为~早知道就好了
- [laravel series 8] out of the world of laravel
- Multi machine LAN office artifact rustdesk use push!!!
- 在命令行登录mysql数据库以及查看版本号
- Data collection and management [9]
猜你喜欢

PostgreSQL has a cross database references are not implemented bug

开发者方案 · 环境监测设备(小熊派物联网开发板)接入涂鸦IoT开发平台

树莓派用VNC Viewer方式远程连接

Mobileone: the mobile terminal only needs 1ms of high-performance backbone

科技云报道:混合办公的B面:安全与效率如何兼得?
![[FPGA mathematical formula] use FPGA to realize common mathematical formulas](/img/b9/e6f219738b106a96b0f5323ee61cca.png)
[FPGA mathematical formula] use FPGA to realize common mathematical formulas

What is the dry goods microservice architecture? What are the advantages and disadvantages?

Technology cloud report: side B of mixed office: how to have both security and efficiency?

Hcie security day41: theoretical learning: information collection and network detection

Runtimeerror in yolox: dataloader worker (PID (s) 17724, 1364, 18928) exited unexpectedly
随机推荐
Logstash starts too slowly or even gets stuck
c语言 --- 分支结构
Data collection and management [15]
Is the increased life insurance off the shelf? What additional life insurance products are available now?
[C language] start a thread
How to back up all data on Apple mobile phone in 2 steps (free)
科技雲報道:混合辦公的B面:安全與效率如何兼得?
[C language] explain the thread recycling function pthread_ join
不使用union实现Mysql 列转行
moudo网络库剖析
044. (2.13) add value to yourself
云主机mysql在本地电脑连接不上
webassembly学习-动态链接
Multi machine LAN office artifact rustdesk use push!!!
Remote connection of raspberry pie in VNC Viewer Mode
1017 A除以B分
Libuv库概述及libevent、libev、libuv对比(转载)
要不是和阿里P7聊过,我也不知道自己是个棒槌
logstash启动过慢甚至卡死
Project development culture