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

我认为贪心也是正确的 强队一定出现在赢得比赛相对多的中产生

Posted by yongheng5871 at 2011-07-23 13:57:41 on Problem 2699
#include <iostream>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <algorithm>
using namespace std;
const int Maxn=15;
struct Play
{
    int w1,w,l;
    bool operator<(const Play &a)const
    {
        if(w==a.w)return l>a.l;
        else return w<a.w;
    }
}player[Maxn];
int main()
{
//    freopen("in.txt","r",stdin);
    int cas;
    char str[Maxn*100];
    scanf("%d",&cas);
    getchar();
    while(cas--)
    {
        stringstream sin;
        gets(str);
        sin<<str;
        int top=0;
        while(sin>>player[top].w)top++;
        for(int i=0;i<top;++i)
        {
            player[i].w1=player[i].w;
            player[i].l=top-1-player[i].w;
        }
        int ans=0;
        for(int i=top-1;i>=0;--i)
        {
            int j;
            for(j=top-1;j>i;--j)
            {
                if(player[i].w==player[j].w)
                {
                    if(player[i].l>player[j].l&&player[j].w1>0){player[i].l--;player[j].w1--;}
                    else
                    {
                        player[j].l--;
                        player[i].w1--;
                    }
                }
                else
                {
                    player[j].l--;
                    player[i].w1--;
                }
                if(player[i].l<0||player[j].l<0||player[i].w1<0)break;
            }
            sort(player+i,player+top);
            if(j==i)ans++;
            else break;
        }
        printf("%d\n",ans);
    }
    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