记录编号 109101 评测结果 AAAAAAAAAA
题目名称 数列 最终得分 100
用户昵称 GravatarSUNYU 是否通过 通过
代码语言 Pascal 运行时间 0.092 s
提交时间 2014-07-07 17:21:35 内存使用 2.00 MiB
显示代码纯文本
program kjdiwdl;
var i,j,k,m,n:longint;sum:int64;
a,b,c,l,r:array[0..100000]of longint;
function  lowbit(x:longint):longint;
begin
exit(x and(-x));
end;

function get(x:longint):longint;
var sum1:longint;
begin
sum1:=0;
while x>0 do
begin
sum1:=sum1+c[x];
x:=x-lowbit(x);
end;
exit(sum1);
end;

procedure add(x,y:longint);
begin
while x<=35000 do
begin
c[x]:=c[x]+y;
x:=x+lowbit(x);
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(a[i]);
a[i]:=a[i]+1;
add(a[i],1);
l[i]:=get(a[i]-1);
end;
fillchar(c,sizeof(c),0);
for i:=n downto 1 do
begin
add(a[i],1);
r[i]:=get(a[i]-1);
end;
for i:=1 to n do
sum:=sum+l[i]*r[i];
writeln(sum);
close(input);close(output);
end.