/ SB域 /

记录详情

Wrong Answer

/usr/bin/ld.bfd: warning: /out/link.res contains output sections; did you forget -T?
# 状态 耗时 内存占用
#1 Accepted 1ms 2.125 MiB
#2 Accepted 1ms 2.145 MiB
#3 Accepted 1ms 2.203 MiB
#4 Accepted 1ms 2.125 MiB
#5 Accepted 6ms 4.125 MiB
#6 Accepted 3ms 4.215 MiB
#7 Accepted 20ms 4.465 MiB
#8 Wrong Answer 38ms 4.75 MiB
#9 Wrong Answer 60ms 5.125 MiB
#10 Wrong Answer 77ms 5.051 MiB

代码

var n,i,ans:longint;
     a,r:array[0..1000000]of longint;
procedure msort(s,t:longint);
var i,j,k,m:longint;
begin
 if s=t then exit;
 m:=(s+t)div 2;
 msort(s,m);
 msort(m+1,t);
 i:=s; j:=m+1; k:=s;
 while (i<=m)and(j<=t) do begin
  if a[i]<=a[j] then begin r[k]:=a[i]; inc(i); inc(k); end
  else begin r[k]:=a[j]; inc(j); inc(k); inc(ans,m-i+1);end;
 end;
 while i<=m do begin r[k]:=a[i]; inc(k); inc(i);end;
 while j<=t do begin r[k]:=a[j]; inc(k); inc(j);end;
 for i:=s to t do  a[i]:=r[i];
end;
begin
 readln(n);
 for i:=1 to n do read(a[i]);
 msort(1,n);
 //for i:=1 to n do write(a[i],' ');
 writeln(ans);
  close(input);
  close(output);
end.

信息

递交者
类型
递交
题目
来自火星的决斗
题目数据
下载
语言
Pascal
递交时间
2017-08-22 15:24:43
评测时间
2017-08-22 15:24:43
评测机
分数
70
总耗时
214ms
峰值内存
5.125 MiB