比赛 |
20120709 |
评测结果 |
C |
题目名称 |
数列 |
最终得分 |
0 |
用户昵称 |
SnowDancer |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2012-07-09 10:44:23 |
显示代码纯文本
var
n,i,j,k,l:longint;
num:array[1..100000] of longint;
tree:array[0..1,1..40000] of longint;
ans:int64;
procedure add(code,k,delta:longint);
begin
while k<40000 do begin
inc(tree[code,k],delta);
k:=k+k and (-k);
end;
end;
function sum(code,k:longint):int64;
begin
sum:=0;
while k>0 do begin
inc(sum,tree[code,k]);
k:=k-k and (-k);
end;
end;
begin
assign(input,'queueb.in'); reset(input);
assign(output,'queueb.out'); rewrite(output);
readln(n);
for i:=1 to n do begin
readln(num[i]);
inc(num[i]);
end;
for i:=2 to n do add(1,num[i],1);
for i:=2 to n-1 do begin
add(0,num[i-1],1);
add(1,num[i],-1);
inc(ans,sum(0,num[i]-1)*sum(1,num[i]-1));
end;
writeln(ans);
close(input); close(output);
end.