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 |
感觉写的还行AC代码struct kdq { int num,id; }a[Max]; int main() { int n,m; int i,j,k,l; scanf("%d%d",&n,&m); for(i=0;i<n;i++) { scanf("%d",&a[i].num); a[i].id=i; } int id=-1; for(i=0;i<m;i++) { int mx=0; for(j=0;j<n;j++) { if(mx<a[j].num) { mx=a[j].num; id=j; } } int mod=a[id].num%(n-1); int add=a[id].num/(n-1); for(j=0;j<n;j++) { if(j!=id&&mod) { a[j].num=a[j].num+1+add; mod--; } else if(j!=id) { a[j].num+=add; } } a[id].num=0; printf("%d\n",id+1); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator