1. 程式人生 > >Codeforces Round #502 Div. 1 + Div. 2 A. The Rank

Codeforces Round #502 Div. 1 + Div. 2 A. The Rank

題意:每個人有4門學科,給出n個人的分數,小明的分數是第一個給出的,問小明的總分排名第幾

思路:水題,求和排序即可。

#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
 
int main() 
{
	int n, a, b, c, d, sum, p, ct = 0;
	int i;
	scanf("%d", &n);
	scanf("%d%d%d%d", &a, &b, &c, &d);
	p = a + b + c + d;
	for (i = 2; i <= n; i++) 
	{
		scanf("%d%d%d%d", &a, &b, &c, &d);
		sum = a + b + c + d;
		if (sum > p) 
		{
			ct++;
		}
	}
	printf("%d\n", ct + 1);
	return 0;
}