|
|
back to boardwa?!?!?!? Edited by author 15.11.2009 18:42 Re: wa?!?!?!? program Project286286; {$APPTYPE CONSOLE} uses SysUtils,Math; var a,b,c:array[0..2000000]of longint; i,j,m,n,f:longint; function RMQ(l,r:longint):longint; var res,i,j:longint; begin i := l + n - 1; j := r + n - 1; res:=0; while i<=j do begin res := max(res,max(a[i],a[j])); i:=(i+1) div 2; j:=(j-1) div 2 end; result:=res; end; begin reset(input,'input.txt'); rewrite(output,'output.txt'); readln(n); for i := 1 to n do readln(c[i]); for i := 1 to n do c[i]:=c[i]-1+c[i-1]; for i := 1 to n do b[i]:=c[i]-c[i-1]; for i := n to 2*n-1 do a[i]:=b[i-n+1]; for i := n-1 downto 1 do a[i]:= max(a[i*2],a[i*2+1]); for i := 1 to n - 1 do if rmq(i+1,n)-c[i-1]>n then begin writeln('NO'); halt(0); end; writeln('YES'); end. |
|
|