|
|
вернуться в форумWhy I got WA?Who can help me,please?Thanks. var n:integer; sz:array[1..5000]of integer; lie:boolean; procedure init; var t,k:integer; c:char; begin fillchar(sz,sizeof(sz),0); readln(n); for t:=1 to n do begin read(c); while c<>' ' do read(c); read(k); if k=0 then readln else readln(sz[t]); end; end; procedure make; var t,k,v,l,m:integer; begin lie:=false; v:=sz[n]; k:=v; for t:=n-1 downto 1 do begin if sz[t]=0 then k:=k+v else if sz[t]>v then begin k:=k+sz[t]; v:=sz[t]; end else begin lie:=true; break; end; end; l:=k; if not lie then begin v:=sz[1]; k:=v; for t:=2 to n do begin if sz[t]=0 then inc(k,v) else if sz[t]<v then begin inc(k,v); v:=sz[t]; end else begin lie:=true; break; end; end; m:=k; if not lie then begin if not((l<=10000)and(m>=10000)) then lie:=true; end; end; end; procedure print; begin if lie then writeln('NO') else writeln('YES'); end; begin init; make; print; end. |
|
|