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 1247. Check a Sequence

wa?!?!?!?
Posted by Roman1994 15 Nov 2009 18:41


Edited by author 15.11.2009 18:42
Re: wa?!?!?!?
Posted by Roman1994 15 Nov 2009 18:41
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.
Re: wa?!?!?!?
Posted by Roman1994 15 Nov 2009 18:42
why wa???