【题解】 CF Round #502 Div. 1 + Div. 2 A.The Rank

目录

 

题目描述

题意分析

AC代码


题目描述

time limit per test  1 second

memory limit per test  256 megabytes

input     standard input

output   standard output

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

input

5
100 98 100 100
100 100 100 100
100 100 99 99
90 99 90 100
100 98 60 99

output

2

input

Copy

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

output

1

Note

In the first sample, the students got total scores: 398, 400, 398, 379, and 357. Among the 5 students, Thomas and the third student have the second highest score, but Thomas has a smaller id, so his rank is 2.

In the second sample, the students got total scores: 369, 240, 310, 300, 300, and 00. Among the 6 students, Thomas got the highest score, so his rank is 1.

题意分析

题意:给你N个人4门课的成绩,第一个人是主角。每个人都有一个独特的序列,就是其编号

           叫你求主角在排序后是第几名。简单模拟一下即可。

 

AC代码

#include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>
#define MAXN 1005
using namespace std;

struct infor
{
    int a;
    int b;
    int c;
    int d;
    int num;
    int sum;
}x[MAXN];

bool cmp(infor q,infor p)
{
    if(q.sum == p.sum)
    {
        return q.num<p.num;
    }
    else
    {
        return q.sum>p.sum;
    }
}
int main()
{
    int n,i,sign;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        cin>>x[i].a>>x[i].b>>x[i].c>>x[i].d;
        x[i].num=i+1;
        x[i].sum = x[i].a + x[i].b + x[i].c + x[i].d;
    }
    sort(x,x+n,cmp);
    for(i=0;i<n;i++)
    {
        if(x[i].num==1)
        {
            cout<<i+1<<endl;
        }
    }

    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据提供的引用内容,Codeforces Round 511 (Div. 1)是一个比赛的名称。然而,引用内容中没有提供与这个比赛相关的具体信息或问题。因此,我无法回答关于Codeforces Round 511 (Div. 1)的问题。如果您有关于这个比赛的具体问题,请提供更多的信息,我将尽力回答。 #### 引用[.reference_title] - *1* [Codeforces Round 860 (Div. 2)题解](https://blog.csdn.net/qq_60653991/article/details/129802687)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Codeforces Round 867 (Div. 3)(A题到E题)](https://blog.csdn.net/wdgkd/article/details/130370975)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Codeforces Round 872 (Div. 2)(前三道](https://blog.csdn.net/qq_68286180/article/details/130570952)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值