|
|
вернуться в форумWHY I TL ON TEST 9!!!!!!!!!!!!!!!!!! Послано Oyh 2 май 2009 08:02 This is my solution: var a:array[0..14000]of longint; b:array[0..100000]of longint; n,i,j,k,max:longint; begin readln(n); b[0]:=1;max:=0; for i:=0 to n-2 do begin readln(a[i]); if a[i]=-1 then begin writeln(max);halt;end; inc(b[a[i]]); if a[i]>max then max:=a[i]; end; readln(j); while j<>-1 do begin inc(i); i:=i mod n; dec(b[a[i]]); a[i]:=j; inc(b[j]); if j>max then max:=j; k:=max; if b[max]=0 then for max:=k-1 downto 0 do if b[max]>0 then break; writeln(max); readln(j); end; end. Can you help me??? Re: WHY I TL ON TEST 9!!!!!!!!!!!!!!!!!! Послано Oyh 2 май 2009 08:11 I got AC now!!!!! var a:array[0..14000]of longint; n,i,j,k,max:longint; b:boolean; begin readln(n); max:=0; for i:=0 to n-2 do begin readln(a[i]); if a[i]=-1 then begin writeln(max);halt;end; if a[i]>max then max:=a[i]; end; readln(j); while j<>-1 do begin inc(i); i:=i mod n; if a[i]=max then b:=true else b:=false; a[i]:=j; if j>max then max:=j; if b then begin max:=0; for k:=0 to n-1 do if a[k]>max then max:=a[k]; end; writeln(max); readln(j); end; end. It can AC in 0.5S!!! |
|
|