读错题意,WA了四次…
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed.

There are nn students, each of them has a unique id (from 11 to nn). Thomas’s id is 11. Every student has four scores correspond to his or her English, German, Math, and History scores. The students are given in order of increasing of their ids.

In the table, the students will be sorted by decreasing the sum of their scores. So, a student with the largest sum will get the first place. If two or more students have the same sum, these students will be sorted by increasing their ids.

Please help John find out the rank of his son.

Input
The first line contains a single integer nn (1≤n≤10001≤n≤1000) — the number of students.

Each of the next nn lines contains four integers aiai, bibi, cici, and didi (0≤ai,bi,ci,di≤1000≤ai,bi,ci,di≤100) — the grades of the ii-th student on English, German, Math, and History. The id of the ii-th student is equal to ii.

Output
Print the rank of Thomas Smith. Thomas’s id is 11.

Examples
inputCopy
5
100 98 100 100
100 100 100 100
100 100 99 99
90 99 90 100
100 98 60 99
outputCopy
2
inputCopy
6
100 80 90 99
60 60 60 60
90 60 100 60
60 100 60 80
100 100 0 100
0 0 0 0
outputCopy
1
Note
In the first sample, the students got total scores: 398398, 400400, 398398, 379379, and 357357. Among the 55 students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is 22.

In the second sample, the students got total scores: 369369, 240240, 310310, 300300, 300300, and 00. Among the 66 students, Thomas got the highest score, so his rank is 11.

#include <iostream>
#include <algorithm>
using namespace std;struct node
{int a, b, c, d, sum;
} stu[1005];int cmp(node a, node b)
{return a.sum > b.sum;
}int main()
{int n;while(cin >> n){if(n == 1){cin >> stu[0].a >> stu[0].b >> stu[0].c >> stu[0].d;cout << '1' << '\n';continue;}bool flag = 1;int ans;cin >> stu[0].a >> stu[0].b >> stu[0].c >> stu[0].d;stu[0].sum = stu[0].a + stu[0].b + stu[0].c + stu[0].d;for(int i = 1; i < n; ++i){cin >> stu[i].a >> stu[i].b >> stu[i].c >> stu[i].d;stu[i].sum = stu[i].a + stu[i].b + stu[i].c + stu[i].d;}sort(stu + 1, stu + n, cmp);for(int i = 1; i < n; ++i)if(stu[0].sum >= stu[i].sum){flag = 0;ans = i;break;}if(!flag)cout << ans << '\n';elsecout << n << '\n';}return 0;
}

A. The Rank相关推荐

  1. Rank() over()的用法

    Rank() over()的用法 创建一个test表,并插入6条数据. CREATE TABLE test (a INT,b INT,c CHAR ) INSERT INTO test VALUES( ...

  2. Sparse low rank approximation

    1. Sparse and low rank approximation (source codes) :http://www.ugcs.caltech.edu/~srbecker/wiki/Main ...

  3. Analytic Functions 分析函数(rank over)

    此篇文章是为了学会rank() over()所写. 官方文档 (DENSE_)RANK( ) OVER ([ query_partition_clause ] order_by_clause) ran ...

  4. python使用numpy中的flatten函数将2D numpy数组拉平为1Dnumpy数组、使用np.linalg.matrix_rank函数计算2D numpy数组的秩(rank)

    python使用numpy中的flatten函数将2D numpy数组拉平为1Dnumpy数组.使用np.linalg.matrix_rank函数计算2D numpy数组的秩(rank) 目录

  5. R语言编写自定义函数使用Wilcoxon符号秩检验(Wilcoxon signed rank)实现多分组非参数成对检验(pairwise)、并使用p.adjust函数调整概率值

    R语言编写自定义函数使用Wilcoxon符号秩检验(Wilcoxon signed rank)实现多分组非参数成对检验(Nonparametric pairwise multiple comparis ...

  6. R语言威尔考克森秩和统计分布函数Wilcoxon rank Sum Statistic Distribution(dwilcox, pwilcox, qwilcox rwilcox)实战

    R语言威尔考克森秩和统计分布函数Wilcoxon rank Sum Statistic Distribution(dwilcox, pwilcox, qwilcox & rwilcox)实战 ...

  7. R语言dplyr包使用arrange函数、group_by函数、mutate函数生成分组数据的排名(rank)实战(Rank Variable by Group):升序排名、降序排名以及相同排名的处理

    R语言dplyr包使用arrange函数.group_by函数.mutate函数生成分组数据的排名(rank)实战(Rank Variables by Group):升序排名.降序排名以及相同排名的处 ...

  8. R语言数据排序函数sort, order rank实战

    R语言数据排序函数sort, order & rank实战 目录 R语言数据排序函数sort, order & rank实战 #sort vs. order vs. rank函数基础 ...

  9. R对数秩检验(log rank test)

    R对数秩检验(log rank test) 对数秩检验(log rank test )是比较两组生存曲线的最常用方法. H0:两组生存率无差异. Ha:两组生存率有差异. 如果检验的P值小于某个显著性 ...

  10. R符号秩检验(WILCOXON SIGNED RANK TEST)

    R符号秩检验(WILCOXON SIGNED RANK TEST) 目录 R符号秩检验(WILCOXON SIGNED RANK TEST) 假设检验 假设检验的应用 符号秩检验

最新文章

  1. R语言使用fs包的dir_delete函数删除指定的文件目录(remove the directory)、举一反三、file_delete函数、link_delete函数可以用来删除文件和文件夹
  2. 苹果回应中情局攻击事件:许多漏洞已经得到解决
  3. 《为自己工作——世界顶级设计师成功法则》—第1章1.7节平衡
  4. java cindy_java枚举应用
  5. android NDK 在Ubuntu10.04开发环境的搭建
  6. ASP.NET Core 数据加解密的一些坑
  7. 2017新生儿爆款名字出炉!90后的父母们最受欢迎的居然是.....
  8. linux使用ping命令ping本机,Linux下使用ping命令判断网络的好坏
  9. ACM-ICPC 2018 徐州赛区网络预赛G (单调队列)
  10. SubRenamer – 字幕批量重命名,自动匹配视频文件与字幕文件[Windows]
  11. 【奇葩笔试】—— printf() 作为函数的参数及其返回值
  12. 使用with语句:记录时间检查路径
  13. Linux镜像克隆网卡流量
  14. mysql数据库链接_连接MySQL数据库
  15. faster rcnn:towards real-time object detection with region proposal network
  16. 除夕最炫烟花代码----跨年必备合集
  17. 罗升阳 android系统源代码情景分析,Android系统源代码情景分析
  18. 基于Qt、FFMpeg的音视频播放器设计四(视频播放进度控制)
  19. 关于ListView的优化
  20. 靠猪八戒接单根本就没什么肉吃,这些才是程序员赚外快的最佳方法!!!

热门文章

  1. 每日一个爬虫练习:爬取喜马拉雅音频
  2. Python跟我说0.1+0.2!=0.3,难道这么多年的数学白学了?
  3. win10系统每次打开软件都会弹出账户控制如何解决
  4. 石头科技打造硬核品牌力 持续出海拓展全球市场
  5. 由世纪互联运营的Microsoft Teams携创新功能正式发布,助力合作伙伴生态共赢
  6. 腾讯云cos html,腾讯云COS对象存储基础设置全攻略记录
  7. 制作自己的CE彻底解决被封问题
  8. Selenium Webdriver系列教程(1)—快速开始
  9. 印度今天正式商用5G网络 号称世界最便宜
  10. 直播app开发所需的三方