题目如上(线段树???),蒟蒻第二眼想法(其实这道题正解是单队的说,但蒟蒻刚学线段树,于是...就)
献上黑历史:
RE是因为蒟蒻数组开太小:第一次开110000;第二次开200000;结果就…………
AC是因为数组开大一点,学学MZL大神的线段树,数组开到800005(⊙o⊙)…
sb代码献上,并在此献上膝盖给MZL
var len,x,n,d,m,lst:longint; op:char; mx:..]of longint; function max(a,b:longint):longint; begin if a>b then exit(a) else exit(b); end; procedure up(rt:longint); begin mx[rt]:=max(mx[rt*],mx[rt*+]); end; procedure update(p,v,l,r,rt:longint); var m:longint; begin if l=r then begin mx[rt]:=v; exit; end; m:=(l+r); ) ,r,rt*+); up(rt); end; function query(left,right,l,r,rt:longint):longint; var m,ret:longint; begin if (left<=l)and(right>=r) then exit(mx[rt]); m:=(l+r); ret:=; )); ,r,rt*+)); exit(ret); end; begin x:=;len:=; readln(n,d); m:=n; do begin readln(op,x); if op='A' then begin inc(len); update(len,(x+lst),n,); end else begin lst:=query(len-x+,len,,n,); writeln(lst); end; dec(m); end; end.
ORZ MZL 阿门
{数组}
ORZ MZL
献上膝盖,大神一次过………………
蒟蒻狂W/R/C/T…………
让MZL赐予你荣耀吧