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 1190. Bar of Chocolate

Could anybody help me?My program always get WA!
Posted by Arsenal 3 Oct 2002 11:56
Here is my program:
const
 inp='1190.txt';

var
 a:array[1..5000]of integer;
 max,min,n,i:integer;
 ans:longint;
 s:char;
 f:text;

begin
 assign(f,inp);reset(f);
 readln(f,n);min:=10000;max:=0;
 for i:=1 to n do
  begin
   read(f,s);
   while s<>' ' do read(f,s);
   read(f,a[i]);
   if a[i]=1 then readln(f,a[i]) else readln(f);
   if a[i]<min then min:=a[i];
   if a[i]>max then
    if max<>0 then begin writeln('NO');halt;end else max:=a[i];
  end;
 close(f);
 ans:=0;
 for i:=1 to n do
  if a[i]=0 then ans:=ans+min else ans:=ans+a[i];
 if ans<>10000 then
  begin
   ans:=0;
   for i:=1 to n do
    if a[i]=0 then ans:=ans+max else ans:=ans+a[i];
  end else begin writeln('YES');halt;end;
 if ans=10000 then writeln('YES') else writeln('NO');
end.