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 |
不知道贪心哪里错了,谁能给个例子就好了,每次都看相临的两个,如果把当前这一批放入下一个等级价格降低, 则将他放到下一个等级,否则直接算在当前等级的买的价格加到答案中, 最后一等后设置最大值,保证不会再向后放. a[n]=100000;p[n]=100000; ans=0; for (i=0;i<n;i++){ if ((a[i]+10)*p[i]>a[i]*p[i+1]) a[i+1]+=a[i]; else ans+=(a[i]+10)*p[i]; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator