记录编号 |
39355 |
评测结果 |
AAAAAAAAAA |
题目名称 |
数列 |
最终得分 |
100 |
用户昵称 |
SnowDancer |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.040 s |
提交时间 |
2012-07-09 15:14:13 |
内存使用 |
0.85 MiB |
显示代码纯文本
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;
var
ans:int64;
begin
ans:=0;
while k>0 do begin
inc(ans,tree[code,k]);
k:=k-k and (-k);
end;
exit(ans);
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.