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

Please HELP!!!
Posted by Serg 17 May 2007 01:27
Please HELP!!! Why WA on test 1???
program Project_kamni;

{$APPtype CONSOLE}

uses
  SysUtils;
var
  s1,s2:string;
  m:array[1..101]of int64;
  a,b,t,n,j,k,r:int64;
  i:longint;
begin
  readln(n);
  s1:='';
  s2:='';
  for i:=1 to n do  begin
   readln(m[i]);
    s1:=s1+'0';
    s2:=s2+'1'
  end;

  t:=992147483645;
  while s1<>s2 do begin
    i:=length(s1);
    while (s1[i]='1') do begin
      s1[i]:='0';
      dec(i);
    end;
    s1[i]:='1';
    a:=0;
    b:=0;
    for i:=1 to n do   begin
      if s1[i]='1' then
       a:=a+m[i]
      else b:=b+m[i];
    end;
    r:=abs(a-b);
    if r<t then
     t:=r;
  end;
  writeln(t);

end.
Why you have WA1?
Posted by BAron 17 Jun 2007 11:02
Please write the test which there did not pass your program.
Please help!!!!!!!!!!!!
I dont know, why I have WA1
Re: Why you have WA1?
Posted by whywaidontknow 17 Jun 2007 16:26
test:

3 2 4 5

you must use read instead of readln
Re: Why you have WA1?
Posted by BAron 19 Jun 2007 11:36
Thanx