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 1346. Intervals of Monotonicity

WA 28 ???
Posted by Aleksander 2 Feb 2009 16:39
Why WA 28?I don't understand.
Here is my code:
program gjkh;
var a,b,ch,n,i,kol,sh,fir,sec,thi:longint;
m:array[1..100001]of longint;
flag:boolean;
begin
read(a);readln(b);
n:=0;
while not seekeof do begin
read(ch);
  if (n=0)or(m[n]<>ch)then begin
  n:=n+1;
  m[n]:=ch;
  end;
end;
flag:=true;
kol:=1;
for i:=1 to n do begin
if (i=1)then fir:=m[i]
  else begin
    if (flag=true)then begin
    sec:=m[i];
    flag:=false;
    end
    else begin
    thi:=m[i];
      if ((thi-sec)*(sec-fir)>0)then begin
      fir:=sec;sec:=thi;
      end
      else begin
      fir:=thi;
      kol:=kol+1;
      flag:=true;
      end;
    end;
  end;
end;
writeln(kol);
end.
Re: WA 28 ???
Posted by r1d1 1 Feb 2010 18:39
1 5
-100000 500000 -70000 800000 -80000
answ: 3

Edited by author 01.02.2010 18:44
Re: WA 28 ???
Posted by timur1992 3 Dec 2010 22:08
Input numbers must not exceed 100000 by absolute value.
Re: WA 28 ???
Posted by StanaAndrei 16 Jun 2021 21:18
why is 3, because there are 4 intervals?