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 1087. The Time to Take Stones

Why WA on test #11?
Posted by волчонок 13 Jul 2005 16:51
I think my programm works correct, but it's WA on test #11!!!
Can somebody tell me where is my mistake, please!!!!!
Re: Why WA on test #11?
Posted by Samsonov Alex 13 Jul 2005 19:26
You use DP, didn't you?

Then look: you should fill array of answers starting from the 1st elememnt, not from K1st. I got the same problem.
Re: Why WA on test #11?
Posted by волчонок 13 Jul 2005 19:57
  Thank you!
     But it's still WA on test #11!
   Here is my code:
*********************
var n,i,k,j,min:integer;
    a:array [0..10000] of 0..2;
    b:array [0..50] of integer;
    q:boolean;


Procedure init;
 Begin
  fillchar(a,sizeof(a),0);

  readln(n,k);
   read(b[1]);
   min:=b[1];

   for i:=2 to k do begin
    read(b[i]);
    if b[i]<min then min:=b[i]
   end;
   a[min]:=1;
    for i:=1 to k do a[min+b[i]]:=2;
End;


Procedure set_a;
 Begin
  q:=false;

  for j:=1 to k do
   if i-b[j]>=min then
    if a[i-b[j]]=1 then begin q:=true; break end;

   if q then a[i]:=2
        else Begin
                a[i]:=1;
                for j:=1 to k do
                 if i+b[j]<=10000 then a[i+b[j]]:=2;
             End;
End;


Procedure main;
 Begin

   For i:=min+1 to n do
    if a[i]=0 then set_a;

End;


Procedure out;
 Begin
  if a[n]=1 then write(2) else write(1);
End;


BEGIN

 init;  main;  out;

END.
************************