测评机: Xeost[5]
得分: 90分
提交日期: 2010-8-8 20:39:00
有效耗时: 1421毫秒
测试结果1: 通过本测试点|有效耗时171ms
测试结果2: 测试结果错误.错误结果为:1286
正确结果应为:2411
测试结果3: 通过本测试点|有效耗时157ms
测试结果4: 通过本测试点|有效耗时156ms
测试结果5: 通过本测试点|有效耗时156ms
测试结果6: 通过本测试点|有效耗时156ms
测试结果7: 通过本测试点|有效耗时157ms
测试结果8: 通过本测试点|有效耗时156ms
测试结果9: 通过本测试点|有效耗时156ms
测试结果10: 通过本测试点|有效耗时156ms
var
i,j,k,n,ll,rr:longint;
l:longint;
a,b:array[0..100] of longint;
procedure qs(l,r:longint);
var
i,j,x,t,kk:longint;
begin
randomize;
i:=l;j:=r;x:=a[(l+r) div 2];
repeat
while (a[i]<x) do inc(i);
while (a[j]>x) do dec(j);
if i<=j then
begin
t:=a[i];a[i]:=a[j];a[j]:=t;
inc(i);dec(j);
end;
until i>j;
if i<r then qs(i,r);
if l<j then qs(l,j);
end;
begin
readln(l,n);l:=l+1;
for i:=1 to n do readln(a[i],b[i]);
qs(1,n);//快排 可以忽略的-----
ll:=a[1];rr:=b[1];
for i:=2 to n do
begin
if a[i]>rr then
begin
k:=k+rr-ll+1;
ll:=a[i];rr:=b[i];
end
else
begin
if b[i]>rr then rr:=b[i];
end;
end;
k:=k+rr-ll+1;
writeln(l-k);
readln;
end.
你这道题的快排运用失误了,读取的起始点和终点,你在快排中只交换了起始点
造成计算的错误。
如,500 3
153 154
150 151
145 146
此数据正确结果为495,用你的算法只能得491.