ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1005. Stone Pile

is it correct we get at #5 WA
Posted by Aybek_TKTL 3 Feb 2006 19:56
var
a,c,b : array[1..10000]of longint;
var n : longint;

procedure sort(m,t:longint);
var y,i,j,w:longint;
begin
    i:=m;j:=t;y:=a[(m+t)div 2];
    repeat
         while a[i]<y do inc(i);
         while a[j]>y do dec(j);
         if i<=j then begin
             w:=a[i];a[i]:=a[j];a[j]:=w;
             inc(i);dec(j);
         end;
    until i>j;
    if i<t then sort(i,t);
    if m<j then sort(m,j);
end;

PRocedure red;
var
i,j : longint;
begin
  readln(n);
    for i:=1  to n do
       read(a[i]);

sort(1,n);
end;

{=-=================}
PRocedure get;
var
i,sum1,sum2 : longint;
begin
sum1:=a[n];
sum2:=0;
   for i:=n-1  downto 1 do
   begin
      if sum1>=sum2 then
         begin
            sum2:=sum2+a[i];
         end
         else
         begin
           sum1:=sum1+a[i];
         end;
   end;
   writeln(abs(sum1-sum2));
end;

{=-=================}
BEgin
    red;
    get;
end.
Re: is it correct we get at #5 WA
Posted by Sid 3 Feb 2006 22:11
Try brudforce =) It realy works
Re: is it correct we get at #5 WA
Posted by Aybek_TKTL 5 Feb 2006 14:04
What does brudforce mean,my english is poor
Sid wrote 3 February 2006 22:11
Try brudforce =) It realy works
Re: is it correct we get at #5 WA
Posted by void off() 5 Feb 2006 15:09
Bruteforce REALLY works in 0.14, 130K:))
2Aybek_TKTL: bruteforce in this case is full search through all possible variants (if u are Russian, then полный перебор).
Re: is it correct we get at #5 WA
Posted by George Skhirtladze 30 May 2010 16:24
I have WA at #5 test too.