Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
单调队列。。。var a:array[0..100,1..3] of longint; n,i,j,k,l,s,x,m,sum:longint; begin readln(n); for i:=1 to n do begin readln(m); fillchar(a,sizeof(a),0); sum:=0; for j:=1 to m do begin read(x); if (sum=0)or(x>a[sum,1]) then begin if j=1 then write(1) else write(' ',1); inc(sum); a[sum,1]:=x; a[sum,2]:=0; a[sum-1,2]:=x-a[sum-1,1]-1; a[sum,3]:=1; end else begin s:=0; while a[sum,2]=0 do begin inc(s,a[sum,3]); dec(sum); end; dec(a[sum,2]); inc(s); inc(sum); a[sum,1]:=x; a[sum,2]:=0; a[sum,3]:=s; write(' ',s); end; end; writeln; end; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator