codeforces 1017 problem A. The Rank(水)

本文介绍了一个简单的竞赛编程问题,即如何确定一名学生的考试成绩在班级中的排名。通过给出的示例代码,我们可以看到如何通过比较每个学生四门科目的总分来解决这个问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A. The Rank

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

Copy

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

output

Copy

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

Copy

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.

 

题意:每个人有4门学科,给出n个人的分数,小明的分数是第一个给出的,问小明的总分排名第几。

思路:分数求和,直接输出名次即可。

#include<iostream>
using namespace std;
int main()
{
    int n,a,b,c,d,sum,ans=1;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b>>c>>d;
        if(i==0) sum=a+b+c+d;
        else if(i!=0&&sum<a+b+c+d) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值