Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

一次ac,不过用的是vector过的。

Posted by 20083331 at 2009-06-11 12:54:59 on Problem 1581
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
using namespace std;

struct player{
    string name;
    int solved;
    int penalty;
};

bool lesscmp(const player& p1,const player& p2)
{
    return p1.penalty < p2.penalty;
}

int main()
{
    vector<player> players;

    int i,n,max_sub=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        player temp;
        cin>>temp.name;

        int prob,pena,j,all_sub=0,all_pena=0;
        for(j=0;j<4;j++)
        {
            cin>>prob>>pena;
            if(pena>0)
            {
                all_sub++;
                all_pena+=(prob-1)*20+pena;
            }
        }
        temp.solved=all_sub;
        temp.penalty=all_pena;
        players.push_back(temp);

        if(all_sub>max_sub)
            max_sub=all_sub;
    }
    vector<player>::iterator det;
    for(det=players.begin();det!=players.end();)
    {
        if(det->solved<max_sub)
            players.erase(det);
        else
            det++;
    }
    sort(players.begin(),players.end(),lesscmp);

    cout<<players[0].name<<" "<<max_sub<<" "<<players[0].penalty;


    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator