[Codeforces]1017A. The Rank

題目URL: http://codeforces.com/contest/1017/problem/A
由於第一個就是要比較的人,因此輸入時就將四個數相加,其餘的輸入相加與之比較,即可排名次

#include<bits/stdc++.h>
using  namespace std;
int total[1005];
main()
{
    int num,a,b,c,d,ans=1;
    cin >> num;
    for(int i=0;i<num;i++)
    {
        cin >> a >>b >>c >>d;
        total[i]=a+b+c+d;
        if(total[0]<total[i] && i>=1)
            ans++;
    }
    cout << ans <<endl;
    return 0;
} 

留言

這個網誌中的熱門文章

[ZJ] b229: TOI 2009 第一題:路徑問題

交大資工(APCS組)(面試&心得)

滿是挫傷的ION CAMP