P1093 [NOIP2007 普及组] 奖学金(模拟排序)

简介: P1093 [NOIP2007 普及组] 奖学金(模拟排序)

Description of the topic



A primary school recently received a grant to offer scholarships to top five students with outstanding academic performance. At the end of the term, each student has three subjects: Chinese, Maths, and English. First according to the total score from high to low sort, if the total score of two students is the same, and then according to the language score from high to low sort, if the total score of two students and language scores are the same, then the provisions of the small number of students in front, so that each student's ranking is the only certainty.


Task: The total score is calculated based on the results of the 3 courses entered, then sorted by the above rules, and finally output the top five students' school numbers and total scores in the ranking order. Note that in the top 5 students, each person's scholarship is different, so you must strictly follow the above rules. For example, in a correct answer, if the output data for the first two rows (two numbers per row: school number, total score) is:


77 279279

55 279279


The meaning of these two rows of data is: the two students with the highest total score are 77th and 55th in turn. The total scores of the two students were 279279 (the total score was equal to the sum of the three subjects of input, mathematics and English), but the students with the number 77 had higher scores in Chinese. If your top two output data is:


55 279279

77 279279


Error handling by output, no score can be scored.


Enter the format



A total of n1 lines.


The 11th behavior is a positive integer n (sle 300)n (≤300), indicating the number of students participating in the selection.


On lines 22 to n1n1, each row has 33 numbers separated by spaces, each between 00 and 100100. The 33 numbers in line jj indicate, in turn, the scores of students with the number j-1j-1 in Chinese, math, and English. Each student's number is numbered 1 to n1 n in the order in which they are entered (exactly the line number minus 11 of the input data).


The data given are correct and need not be tested.


Thanks to Huang Xiao U Drinks for correcting the input format


The output format



There are 5 rows, each of which is a positive integer separated by spaces, representing the number and total score of the first 55 students in turn.


A sample of the input and output



Enter #1 copy


1. 6
2. 90 67 80
3. 87 66 91
4. 78 89 91
5. 88 99 77
6. 67 89 64
7. 78 89 98


Output #1 copy

1. 6 265
2. 4 264
3. 3 258
4. 2 244
5. 1 237
6.


Enter #2 copy

1. 8
2. 80 89 89
3. 88 98 78
4. 90 67 80
5. 87 66 91
6. 78 89 91
7. 88 99 77
8. 67 89 64
9. 78 89 98


Output #2 copy

1. 8 265
2. 2 264
3. 6 264
4. 1 258
5. 5 258


题意分析就是模拟排序判断;

#include<bits/stdc++.h>
const int maxn=1e6+7;
using namespace std;
struct node
{
  int sum;
  int x,y,z;
  int num;
}s[maxn];
bool cmp(node a,node b)
{
  if(a.sum>b.sum)return 1;
  else if(a.sum<b.sum)return 0;
  else
  {
    if(a.x>b.x)return 1;
    else if(a.x<b.x) return 0;
    else
    {
      if(a.num<b.num)return 1;
      else return 0; 
    }
  }
}
int main()
{
  int t;
  cin>>t;
  for(int i=1;i<=t;i++)
  {
    s[i].num=i;
    cin>>s[i].x>>s[i].y>>s[i].z;
    s[i].sum=s[i].x+s[i].y+s[i].z;
  }
  sort(s+1,s+1+t,cmp);
  for(int i=1;i<=5;i++)
  {
    cout<<s[i].num<<' '<<s[i].sum<<endl; 
  }
}
相关文章
|
7月前
|
存储 人工智能 编解码
意图共鸣科技《AI记忆链商业化白皮书2.0》深度:三元悖论,从订阅制到双轨制的范式转移
本文揭示AI订阅制的“三元悖论”:用户不敢深用、企业难盈利、数据难自主。根源在于固定收费与浮动算力成本的根本错配。借鉴电信模式,提出“双轨制”——月租保记忆(存储)、按Token付费(算力),实现公平、透明、可迁移、可持续的新范式。
653 6
|
6月前
|
自然语言处理 IDE Java
全新Eclipse 2025 开发工具全方位超详细下载安装教程
Eclipse 2025是免费开源、跨平台的专业IDE,主打Java开发,全面支持Java 24/25预览版;内置AI编程助手(Copilot),性能大幅提升,UI全面现代化;原生多语言支持,插件生态丰富,企业级工具齐全,季度更新,可商用、可深度定制。(239字)
549 0
|
安全 网络安全 数据安全/隐私保护
【专栏】IT 知识百科:访问控制列表(ACL)是网络安全的关键机制,用于定义和管理网络资源的访问权限
【4月更文挑战第28天】访问控制列表(ACL)是网络安全的关键机制,用于定义和管理网络资源的访问权限。ACL工作原理包括定义规则、匹配规则和执行操作。标准ACL基于源IP过滤,扩展ACL则提供更多筛选条件。时间及用户基础的ACL提供更细化的控制。优点在于增强安全性和精细管理,但管理复杂性和性能影响也是挑战。未来,ACL将趋向智能化和自动化,与更多安全技术结合,以提升网络安全。**
1468 0
|
搜索推荐 小程序 开发工具
Gitee推荐项目!埋点+用户分析系统,适合中小团队的开源方案
一款好用的用户行为分析工具,对产品经理、运营人员和开发者来说,都越来越重要。 目前市面上主流的工具,不是价格高昂、数据不透明,就是部署复杂,很难维护。 ClkLog,适合中小团队的开源方案,已经在Gitee上开源,社区也在持续更新中。
1350 7
📣参与云大使阿里云百炼狂欢购,瓜分限量大奖品
阿里云百炼狂欢季盛大开启!活动时间:6月2日-6月30日,全民参与零门槛。邀请新客下单即可享受最高45%返利+9万奖金。活动奖励丰富:超高返佣、现金大礼包、专属补贴等你来拿!三步轻松参与:报名成为云大使、设置补贴、分享裂变。阶梯拉新奖最高4万元,消费加码奖最高5万元。立即行动,抢占名额,扫码或点击链接报名,变身“云赚王”!
618 0
|
机器学习/深度学习 人工智能 开发者
【AI系统】昇思 MindSpore 关键特性
本文介绍华为自研AI框架昇思MindSpore,一个面向全场景的AI计算框架,旨在提供统一、高效、安全的平台,支持AI算法研究与生产部署。文章详细阐述了MindSpore的定位、架构、特性及在端边云全场景下的应用优势,强调其动静态图统一、联邦学习支持及高性能优化等亮点。
864 7
【AI系统】昇思 MindSpore 关键特性
|
安全 测试技术 量子技术
量子计算硬件:超导量子比特的最新进展
量子计算作为信息技术的前沿领域,超导量子比特作为其核心组件,近年来取得了显著进展。本文介绍了超导量子比特的基本原理、制造与性能提升、最新技术成果及未来展望,展示了其在密码学、化学和材料科学等领域的潜在应用,预示着量子计算时代的到来。
|
SQL 安全 Java
Android经典面试题之Kotlin中object关键字实现的是什么类型的单例模式?原理是什么?怎么实现双重检验锁单例模式?
Kotlin 单例模式概览 在 Kotlin 中,`object` 关键字轻松实现单例,提供线程安全的“饿汉式”单例。例如: 要延迟初始化,可使用 `companion object` 和 `lazy` 委托: 对于参数化的线程安全单例,结合 `@Volatile` 和 `synchronized`
879 6
|
弹性计算 运维 监控
停止、重启或释放ECS实例
停止、重启或释放ECS实例
2311 4
sourcetree设置忽略文件
sourcetree设置忽略文件
1418 0