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 |
Re:终于过了,好像可以o(n)In Reply To:Re:终于过了,好像可以o(n) Posted by:chenyukang at 2009-07-15 23:20:19 > > 貌似你贴的这个代码是错误的 > 测试数据比较弱 所以能通过 > 你看这组数据: > 1 > 3 > -10 1 2 > > 你的结果是:-7 > 正确答案应该是 3 吧? temp2=(temp2>temp1?temp2:temp1)+a[i]; //两种情况。是否包含i-1 > > if(temp2>max)max=temp2; > temp3=(temp3>0?temp3:0)+a[i-1]; //更新 > temp1=temp1>temp3?temp1:temp3; //是否包含i-1 把temp3 和 temp1 这连个句子放在temp2前就对了,总的思路是对的 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator