|
|
вернуться в форумI'm WA in #21. Can somebody help me ? Thanks a lot . Here is my code : Const tfi = ''; tfo = ''; max = 10000 + 1; Type arr1I = array [0..max] of integer ; Var f : arr1I ; a,b : integer ; res : integer ; fi,fo : text ; Procedure Readfile; Var i : integer ; Begin Assign(fi,tfi); Reset(fi); Readln(fi,a,b); For i := a to b do read(fi,f[i]); Close(fi); End; {--------------------------------------------------------------------} Procedure Process; Var i,x,j : integer ; Begin res := 1; If b - a = 1 then exit; res := 0; i := a; Repeat Inc(res); If f[i] <= f[i + 1] then Begin x := f[i + 1]; j := i + 1; Repeat If x <= f[j + 1] then Begin x := f[j + 1]; Inc(j); End Else break; If j = b then exit; Until false; i := j + 1; End Else Begin x := f[i + 1]; j := i + 1; Repeat If x >= f[j + 1] then Begin x := f[j + 1]; Inc(j); End Else break; If j = b then exit; Until false; i := j + 1; End; If i = b then Begin Inc(res); break; End; Until i > b; End; {--------------------------------------------------------------------} Procedure Writefile; Begin Assign(fo,tfo); Rewrite(fo); Writeln(fo,res); Close(fo); End; {--------------------------------------------------------------------} Begin Readfile; Process; Writefile; End. Edited by author 21.12.2005 09:16 |
|
|