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; 
  }
}
相关文章
|
前端开发 安全 测试技术
短剧cps分销模式系统开发技术规则
短剧CPS分销模式系统开发涉及系统架构设计、数据库设计与实现、功能模块开发、安全性与合规性及开发与测试流程。系统采用前后端分离、微服务架构和容器化技术,确保高性能和可扩展性。功能模块涵盖用户管理、短剧管理、分销机制、支付接口和数据分析,确保系统的全面性和安全性。
|
文字识别 数据可视化 算法
视觉智能开放平台产品使用合集之生成链接后访问的时候提示签名不匹配,该如何处理
视觉智能开放平台是指提供一系列基于视觉识别技术的API和服务的平台,这些服务通常包括图像识别、人脸识别、物体检测、文字识别、场景理解等。企业或开发者可以通过调用这些API,快速将视觉智能功能集成到自己的应用或服务中,而无需从零开始研发相关算法和技术。以下是一些常见的视觉智能开放平台产品及其应用场景的概览。
117 0
视觉智能开放平台产品使用合集之生成链接后访问的时候提示签名不匹配,该如何处理
|
Rust 编译器 C++
Rust之helloworld
Rust之helloworld
128 0
|
应用服务中间件
tomcat启动报错:Internal error (java.lang.IllegalStateException): Duplicate key org.jetbrains.jps.model.module.impl.JpsModuleImpl@548a102f
tomcat启动报错:Internal error (java.lang.IllegalStateException): Duplicate key org.jetbrains.jps.model.module.impl.JpsModuleImpl@548a102f
806 0
tomcat启动报错:Internal error (java.lang.IllegalStateException): Duplicate key org.jetbrains.jps.model.module.impl.JpsModuleImpl@548a102f
|
数据采集 搜索推荐 安全
独立站海外推广的方法有哪些?
答案是:海外SEO可以持续建设GPB外链+优质内容可提升排名。 内容营销 内容营销是海外推广的核心。 高质量的内容能够为目标受众带来价值,从而提高独立站的知名度和信誉。 博客与文章 通过定期发布关于行业趋势、产品使用教程或案例研究的博客和文章,你可以吸引潜在客户的注意。 视频内容 视频内容是另一个非常有效的方式。 可以考虑制作产品演示、教程或访谈来与受众建立联系。
224 2
独立站海外推广的方法有哪些?
|
存储 缓存 算法
49.【面试宝典】面试宝典-JVM内存模型
【面试宝典】面试宝典-JVM内存模型
49.【面试宝典】面试宝典-JVM内存模型
|
前端开发
Day04:Gin框架快速入门03 bind绑定器| 青训营(二)
Day04:Gin框架快速入门03 bind绑定器| 青训营
|
关系型数据库 Java 数据库连接
|
算法
Manacher算法 - 求最长回文串的利器
求最长回文串的利器 - Manacher算法 Manacher主要是用来求某个字符串的最长回文子串. 不要被manacher这个名字吓倒了,其实manacher算法很简单,也很容易理解,程序短,时间复杂度为O(n). 求最长回文子串这个问题,我听说有个分治+拓展kmp的算法,后缀数组也可以. 但是对于求回文串来说,manacher算法肯定有很多其他算法没有的优点。
1184 0