|
|
вернуться в форумHelp me!!why WA#5,who know test 5. var a:array[0..10000]of integer; max,i,j,n,k,l,group1,group2:longint; begin read(n); for i:=1 to n do read(a[i]); for i:=1 to n-1 do begin k:=i; max:=a[i]; for j:=i+1 to n do if a[j]>max then begin max:=a[j]; k:=j; end; a[k]:=a[i]; a[i]:=max; end; for i:=3 to n do if group1<group2 then group1:=group1+a[i] else group2:=group2+a[i]; writeln(abs(group1-group2)); end. Re: Help me!!why WA#5,who know test 5. Послано ile 14 апр 2010 03:28 this is wrong approach. the right solution is DP or bruteforcing all combinations. Re: Help me!!why WA#5,who know test 5. Someone have function DP of this problem Re: Help me!!why WA#5,who know test 5. use BruteForce my program with it works good difficulty of my algorithm is O(n* pow(2,20) = O(n*1048576) |
|
|