测评机: Xeond[6]
得分: 30分
有效耗时: 641毫秒
测试结果1: 通过本测试点|有效耗时219:ms
测试结果2: 通过本测试点|有效耗时172:ms
测试结果3: 通过本测试点|有效耗时250:ms
测试结果4: 选手程序运行超过时限
测试结果5: 测试结果错误.
错误结果为:22241
正确结果应为:724368
测试结果6: 选手程序运行超过时限
测试结果7: 测试结果错误.
错误结果为:22241
正确结果应为:9095711
测试结果8: 选手程序运行超过时限
测试结果9: 测试结果错误.
错误结果为:22241
正确结果应为:57902100
测试结果10: 选手程序运行超过时限
program p173;
var f:array[1..20000,1..20000]of integer;
a:array[1..20000]of longint;
n,i,j,k,p:integer;
s:longint;
m:boolean;
begin
read(n);
for i:=1 to n do read(a[i]);
for j:=2 to n do
for i:=1 to n-j+1 do
begin
m:=false;
for k:=1 to j-1 do if a[i+k]<a[i] then
begin
m:=true;
break
end;
if not m then continue;
for p:=k+1 to j-1 do
if (a[i+p]>=a[i+k])and(a[i+p]<a[i]) then
begin
f[i,j]:=f[i,j]+f[i+k,p-k+1]+1;
k:=p
end;
if a[i+k]<a[i] then f[i,j]:=f[i,j]+f[i+k,p-k+1]+1
end;
for i:=1 to n do inc(s,f[i,n-i+1]);
write(s)
end.
#include<cstdio>
using namespace std;
int main (void){
int a[20000],n,count=0;
scanf ("%d",&n);
for (int i=0;i<n;++i)
scanf ("%d",&a[i]);
for (int i=0;i<n-1;++i)
for (int j=i+1;j<n;++j)
if (a[j]<a[i]) ++count;
printf ("%d",count);
//while(1);
return 0;
}
查看状态 Show Status
状态题目:Fish学数学
题目编号:173-Fish学数学 查看该题
状态: Accepted
测评机: Xeond[6]
得分: 100分
提交日期: 2008-11-9 15:47:00
有效耗时: 2438毫秒
测试结果1: 通过本测试点|有效耗时47:ms
测试结果2: 通过本测试点|有效耗时47:ms
测试结果3: 通过本测试点|有效耗时46:ms
测试结果4: 通过本测试点|有效耗时47:ms
测试结果5: 通过本测试点|有效耗时47:ms
测试结果6: 通过本测试点|有效耗时78:ms
测试结果7: 通过本测试点|有效耗时125:ms
测试结果8: 通过本测试点|有效耗时391:ms
测试结果9: 通过本测试点|有效耗时594:ms
测试结果10: 通过本测试点|有效耗时1016:ms
可以将原序列归并排序,统计总共的交换次数
也可以建二叉搜索树,在每个节点增加一个数据域进行统计