比赛 20121109 评测结果 WAWWWWTTTT
题目名称 三元数对 最终得分 10
用户昵称 稠翼 运行时间 4.051 s
代码语言 Pascal 内存使用 0.46 MiB
提交时间 2014-09-13 20:49:02
显示代码纯文本
program cogs1260;
var
   a:array[1..30000]of longint;
   i,j,k,n:longint;
   ans:int64;
procedure init;
begin
     assign(input,'three.in');reset(input);
     assign(output,'three.out');rewrite(output);
end;
procedure sort(l,r:longint);
var
   i,j,mid,t:longint;
begin
     i:=l;j:=r;mid:=a[random(r-l+1)+l];
     repeat
     while a[i]<mid do inc(i);
     while a[j]>mid do dec(j);
     if j>=i then
     begin
          t:=a[i];a[i]:=a[j];a[j]:=t;
          inc(i);
          dec(j);
     end;
     until i>j;
     if r>i then sort(i,r);
     if l<j then sort(l,j);
end;
procedure main;
begin
     readln(n);
     for i:=1 to n do readln(a[i]);
     for i:=1 to n-2 do
         for j:=i+1 to n-1 do
             if a[i]<a[j] then
                for k:=n downto j+1 do
                    if a[k]>a[j] then inc(ans) else break;
     writeln(ans);
end;
begin
     init;
     main;
     close(output);
end.//complete by chouyi20140913