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

can anyone tell me why WA
Posted by liuzhizhi 19 Jul 2004 16:25
var
  n:integer;
 total:real;
  t:array[1..5000]of shortint;
  v:array[1..5000]of real;
procedure init;
 var
  I,b,j:integer;
  a:char;
  c:real;
 begin
  readln(N);
  for i:=1 to n do
   begin
    read(a);
    while a<>' ' do read(a);
    read(b);
    if b=1 then
     begin
      read(c);
      v[i]:=c;
      t[i]:=1;
      for j:=1 to i-1 do
       if t[j]=0 then
        begin
         total:=total+c;
         t[j]:=1;
         v[j]:=c;
        end else
        if t[j]=1 then
         begin
          if c>v[j] then
           begin
            write('NO');
            halt;
           end;
         end;
      total:=total+c;
     end else t[i]:=0;
     readln;
   end;
 end;

begin
 init;
 if total>100 then write('NO') else write('YES');
end.