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 1109. Conference

Sombody help me please ,I get WA and I don't know why.
Posted by Pooya 6 Feb 2003 02:22
const
    Max                 = 30001;
var
    A                   : array[1..Max+1]of longint;
    D                   : array[1..Max+1]of longint;
    x ,y ,I ,J ,K ,N    : longint;

begin
    for I := 1 to Max do
    begin
        A[I] := Max+1;
        D[I] := 0;
    end;

    read(N);

    for I := 1 to N do
    begin
        read(x ,y);
        if A[x] > y then
          A[x] := y;
    end;

    for I := Max downto 1 do
        if A[I] <> Max+1 then
        begin
            D[I] := D[I+1];
            if D[I] < (1 + D[A[I]+1]) then
                D[I] := 1 + D[A[I]+1];
        end
        else
            D[I] := D[I+1];

    write(D[1]);
end.
Sorry I realized my bug. There are two problems with name conference.
Posted by Pooya 8 Feb 2003 20:52
> const
>     Max                 = 30001;
> var
>     A                   : array[1..Max+1]of longint;
>     D                   : array[1..Max+1]of longint;
>     x ,y ,I ,J ,K ,N    : longint;
>
> begin
>     for I := 1 to Max do
>     begin
>         A[I] := Max+1;
>         D[I] := 0;
>     end;
>
>     read(N);
>
>     for I := 1 to N do
>     begin
>         read(x ,y);
>         if A[x] > y then
>           A[x] := y;
>     end;
>
>     for I := Max downto 1 do
>         if A[I] <> Max+1 then
>         begin
>             D[I] := D[I+1];
>             if D[I] < (1 + D[A[I]+1]) then
>                 D[I] := 1 + D[A[I]+1];
>         end
>         else
>             D[I] := D[I+1];
>
>     write(D[1]);
> end.
>