nyoj 596-谁是最好的Coder (greater, less)

596-谁是最好的Coder


内存限制:64MB 时间限制:1000ms 特判: No
通过数:15 提交数:28 难度:0

题目描述:

计科班有很多Coder,帅帅想知道自己是不是综合实力最强的coder。
帅帅喜欢帅,所以他选了帅气和编程水平作为评选标准。
每个同学的综合得分是帅气程度得分与编程水平得分的和。
他希望你能写一个程序帮他一下。

输入描述:

数据有多组。
输入一个数n,代表计科班的总人数。
接下来有n行数,一行数有两个数a,b。
其中a代表该同学的编程水平,b代表该同学的帅气程度。
n=0表示输入结束。

输出描述:

每组数据占一行,输出所有同学中综合得分最高的分数。

样例输入:

5
9 10
7 11
1 6
5 7
3 5
2
7 3
7 6
0

样例输出:

19
13

C/C++ :

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <climits>
#include <bitset>
#define PI 3.1415926

using namespace std;
const int MY_MAX = 10005;
int N, A[MY_MAX];

int main()
{
    while (~scanf("%d", &N), N)
    {
        int temp1, temp2;
        for (int i = 0; i < N; ++ i)
        {
            scanf("%d%d", &temp1, &temp2);
            A[i] = temp1 + temp2;
        }
        sort(A,A+N, greater<int>());
        printf("%d
", A[0]);
    }

    return 0;
}
原文地址:https://www.cnblogs.com/GetcharZp/p/9349022.html