Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
wa了很多次啊,终于过了,附代码#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator