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

Re:回复

Posted by CCNUhaitun at 2009-08-16 21:40:03 on Problem 1505
In Reply To:求教大牛! Posted by:ct314171238 at 2008-08-12 19:16:31
算出最小的那个最大值max后,用此方法即可解决这个输出问题。
	j=m;      i=m+k-1;
for(v=k; v>=1; v--){    //v代表抄写员的序号。
    s=0;     //s表示第v段的和,只要s<=max即可。
     while(s+p[j]<=max && j>=v){ //如果j<v,就会出现前v-1个人中,
                           //有人没分到copy任务。每个人至少要有一个copy任务。
	ans[i]=p[j];
	s+=p[j];
	i--;     j--;
     }
     ans[i]=-1;    //-1代表这个位置应该输出 /
     i--;
}
希望能对你有所帮助。

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