首页
学习
活动
专区
圈层
工具
发布
30 篇文章
1
PAT (Basic Level) Practice (中文)1054 求平均值 (20 分)
2
PAT (Basic Level) Practice (中文)1051 复数乘法 (15 分)
3
PAT (Basic Level) Practice (中文)1050 螺旋矩阵 (25 分)
4
PAT (Basic Level) Practice (中文)1046 划拳 (15 分)
5
PAT (Basic Level) Practice (中文)1045 快速排序 (25 分)
6
PAT (Basic Level) Practice (中文)1047 编程团体赛 (20 分)
7
PAT (Basic Level) Practice (中文)1043 输出PATest (20 分)
8
PAT (Basic Level) Practice (中文)1042 字符统计 (20 分)
9
PAT (Basic Level) Practice (中文)1040 有几个PAT (25 分)
10
PAT (Basic Level) Practice (中文)1038 统计同成绩学生 (20 分)
11
PAT (Basic Level) Practice (中文)1036 跟奥巴马一起编程 (15 分)
12
PAT (Basic Level) Practice (中文)1034 有理数四则运算 (20 分)
13
PAT (Basic Level) Practice (中文)1032 挖掘机技术哪家强 (20 分)
14
PAT (Basic Level) Practice (中文)1031 查验身份证 (15 分)
15
PAT (Basic Level) Practice (中文)1030 完美数列 (25 分)
16
PAT (Basic Level) Practice (中文)1029 旧键盘 (20 分)
17
PAT (Basic Level) Practice (中文)1028 人口普查 (20 分)
18
PAT (Basic Level) Practice (中文)1027 打印沙漏 (20 分)
19
PAT (Basic Level) Practice (中文)1025 反转链表 (25 分)
20
PAT (Basic Level) Practice (中文)1053 住房空置率 (20 分)
21
PAT (Basic Level) Practice (中文)1024 科学计数法 (20 分)
22
PAT (Basic Level) Practice (中文)1022 D进制的A+B (20 分)
23
PAT (Basic Level) Practice (中文)1049 数列的片段和 (20 分)
24
PAT (Basic Level) Practice (中文)1021 个位数统计 (15 分)
25
PAT (Basic Level) Practice (中文)1048 数字加密 (20 分)
26
PAT (Basic Level) Practice (中文)1019 数字黑洞 (20 分)
27
PAT (Basic Level) Practice (中文)1017 A除以B (20 分)
28
PAT (Basic Level) Practice (中文)1016 部分A+B (15 分)
29
PAT (Basic Level) Practice (中文)1015 德才论 (25 分)
30
PAT (Basic Level) Practice (中文)1014 福尔摩斯的约会 (20 分)

PAT (Basic Level) Practice (中文)1015 德才论 (25 分)

1015 德才论 (25 分)

宋代史学家司马光在《资治通鉴》中有一段著名的“德才论”:“是故才德全尽谓之圣人,才德兼亡谓之愚人,德胜才谓之君子,才胜德谓之小人。凡取人之术,苟不得圣人,君子而与之,与其得小人,不若得愚人。”

现给出一批考生的德才分数,请根据司马光的理论给出录取排名。

输入格式:

输入第一行给出 3 个正整数,分别为:N(≤10​5​​),即考生总数;L(≥60),为录取最低分数线,即德分和才分均不低于 L 的考生才有资格被考虑录取;H(<100),为优先录取线——德分和才分均不低于此线的被定义为“才德全尽”,此类考生按德才总分从高到低排序;才分不到但德分到线的一类考生属于“德胜才”,也按总分排序,但排在第一类考生之后;德才分均低于 H,但是德分不低于才分的考生属于“才德兼亡”但尚有“德胜才”者,按总分排序,但排在第二类考生之后;其他达到最低线 L 的考生也按总分排序,但排在第三类考生之后。

随后 N 行,每行给出一位考生的信息,包括:准考证号 德分 才分,其中准考证号为 8 位整数,德才分为区间 [0, 100] 内的整数。数字间以空格分隔。

输出格式:

输出第一行首先给出达到最低分数线的考生人数 M,随后 M 行,每行按照输入格式输出一位考生的信息,考生按输入中说明的规则从高到低排序。当某类考生中有多人总分相同时,按其德分降序排列;若德分也并列,则按准考证号的升序输出。

输入样例:

代码语言:javascript
复制
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

输出样例:

代码语言:javascript
复制
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 90

思路,老套路了,结构体排序,只是稍微复杂一点,注意优先级读清题意即可~

代码语言:javascript
复制
// luogu-judger-enable-o2
#include<bits/stdc++.h>
#include<unordered_set>
#define rg register ll
#define inf 2147483647
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define ll long long
#define maxn 300005
#define lb(x) (x&(-x))
const double eps = 1e-6;
using namespace std;
inline ll read()
{
	char ch = getchar(); ll s = 0, w = 1;
	while (ch < 48 || ch>57) { if (ch == '-')w = -1; ch = getchar(); }
	while (ch >= 48 && ch <= 57) { s = (s << 1) + (s << 3) + (ch ^ 48); ch = getchar(); }
	return s * w;
}
inline void write(ll x)
{
	if (x < 0)putchar('-'), x = -x;
	if (x > 9)write(x / 10);
	putchar(x % 10 + 48);
}
ll n,l,h;
struct node
{
    string a;
    ll x,y;
}p[maxn],q[maxn],p1[maxn],p2[maxn];
inline bool cmp(const node &c,const node &b)
{   
    if(c.x+c.y==b.x+b.y&&c.x==b.x)return c.a<b.a;
    if(c.x+c.y==b.x+b.y)return c.x>b.x;
    return c.x+c.y>b.x+b.y;
}
int main()
{
    cin>>n>>l>>h;
    ll tot=0,tot1=0,tot2=0,tot3=0;
    for(rg i=1;i<=n;i++)
    {
        string tep;
        ll a,b;
        cin>>tep>>a>>b;
        if(a>=h&&b>=h)
           {
               q[++tot1].a=tep,q[tot1].x=a,q[tot1].y=b;
           }
        else if(a>=h&&b>=l)
        {
           p[++tot].a=tep,p[tot].x=a,p[tot].y=b;
        }
        else if(a>=l&&b>=l&&a>=b)
        {
             p1[++tot2].a=tep,p1[tot2].x=a,p1[tot2].y=b;
        }
        else if(a>=l&&b>=l)
        {
             p2[++tot3].a=tep,p2[tot3].x=a,p2[tot3].y=b;
        }
    }
    sort(q+1,q+1+tot1,cmp);
    sort(p+1,p+1+tot,cmp);
    sort(p1+1,p1+1+tot2,cmp);
    sort(p2+1,p2+1+tot3,cmp);
    cout<<tot1+tot2+tot3+tot<<endl;
    for(rg i=1;i<=tot1;i++)
    {
        cout<<q[i].a<<" "<<q[i].x<<" "<<q[i].y<<endl;
    }
     for(rg i=1;i<=tot;i++)
    {
        cout<<p[i].a<<" "<<p[i].x<<" "<<p[i].y<<endl;
    }
     for(rg i=1;i<=tot2;i++)
    {
        cout<<p1[i].a<<" "<<p1[i].x<<" "<<p1[i].y<<endl;
    }
     for(rg i=1;i<=tot3;i++)
    {
        cout<<p2[i].a<<" "<<p2[i].x<<" "<<p2[i].y<<endl;
    }
   	return 0;
}
下一篇
举报
领券