签到题。表示今天虽然废了一天但是还是坚持写了题的。
单调栈搞定。
因为打球把小指头打残了所以不想敲include所以写了pascal,然后发现include不用小指。
const
maxn = 100009;
var
n, i, t: longint;
a, st, ans: array[0 .. maxn] of longint;
begin
readln(n);
for i := 1 to n do
readln(a[i]);
t := 0;
for i := n downto 1 do begin
while (t > 0) and (a[i] >= a[st[t]]) do
dec(t);
if t = 0 then
ans[i] := 0
else
ans[i] := st[t];
inc(t);
st[t] := i;
end;
for i := 1 to n do
writeln(ans[i]);
end.