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

wa了很多次啊,终于过了,附代码

Posted by 1004115224 at 2012-08-10 09:58:05 on Problem 3665
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node
{
    int time;
    int num;
    //int v;
}p[1001];
bool pai(node a,node b)
{
    if(a.time==b.time)return a.num>b.num;
    else return a.time<b.time;
}
bool pai2(node a,node b)
{
    return a.num<b.num;
}
int main()
{
    int n,t;
    scanf("%d%d",&n,&t);
    int m=n-1;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&p[i].time);
        //p[i].v=0;
        p[i].num=i+1;
    }
    while(t--)
    {
        sort(p,p+n,pai);
        cout<<p[m].num<<endl;
        for(int j=0;j<m;j++)
        {
            p[j].time+=p[m].time/m;
        }
        if(p[m].time%m!=0)
        {
            sort(p,p+m,pai2);
            int r=p[m].time%m;
            for(int j=0;j<r;j++)p[j].time+=1;
        }
        p[m].time=0;
    }
    //for(int i=0;i<t;i++)cout<<p[n-i%n-1].num<<endl;
    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