NKTREE - Cây nhị phân tìm kiếm

Tác giả: happyboy99x

Ngôn ngữ: Pascal

var min, max, pre, now: longint;

BEGIN
    read(pre); min := low(longint); max := high(longint);
    while not seekEOF do
    begin
        read(now);
        if(now = pre) or (now < min) or (now > max) then
        begin
            writeln('NO');
            halt;
        end;
        if(now < pre) then max := pre - 1
        else min := pre + 1;
        pre := now;
    end;
    writeln('YES');
END.

Download