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 1579. Coat Transportation

It drives me crazy!
Posted by yuyan 25 Mar 2009 04:55
    What's the test 15?Can somebody tell me?
    Thank you.
    Here is my code with O(N) soulution which is get WA on #15
program coats;
const
  maxn=200100;
var
  g,next,t:array [0..maxn] of int64;
  l,a:array [0..maxn] of int64;
  i,k,m,n:longint;
  r:int64;
procedure init;
  begin
    read(n,r);
    for i:=1 to n do read(a[i]);
  end;
procedure solve;
  begin
    m:=1;k:=1;
    next[n]:=g[1];g[1]:=n;l[1]:=a[n];t[1]:=1;
    for i:=n-1 downto 1 do
      begin
        if l[k]-a[i]>r
          then begin
                 next[i]:=g[k];g[k]:=i;l[k]:=a[i];inc(t[k]);
                 inc(k);if k>m then k:=1;
                 continue;
               end;
        inc(m);next[i]:=g[m];g[m]:=i;l[m]:=a[i];t[m]:=1;
      end;
    writeln(m);
    for i:=m downto 1 do
      begin
        write(t[i]);
        r:=g[i];
        while r<>0 do
          begin
            write(' ',r);
            r:=next[r];
          end;
        writeln;
      end;
  end;
begin
  assign(input,'coats.in');reset(input);
  assign(output,'coats.out');rewrite(output);
  init;
  solve;
  close(input);close(output);
end.
Re: It drives me crazy!
Posted by yuyan 26 Mar 2009 05:34
    Please help!
Re: It drives me crazy!
Posted by yuyan 26 Mar 2009 12:27
   Nothing serious.Just a big and hidden mistake in my program.
   Thank you anyway.