讨论 / 请问哪里错了!?
woshitoupi 2012-11-08 03:46:00
点我顶贴 收藏 删除
测试结果1: 通过本测试点|有效耗时172ms

测试结果2: 通过本测试点|有效耗时156ms

测试结果3: 通过本测试点|有效耗时157ms

测试结果4: 测试结果错误.错误结果为:143 正确结果应为:99

测试结果5: 通过本测试点|有效耗时156ms

测试结果6: 通过本测试点|有效耗时156ms

测试结果7: 通过本测试点|有效耗时172ms

测试结果8: 通过本测试点|有效耗时156ms

测试结果9: 通过本测试点|有效耗时157ms

测试结果10:通过本测试点|有效耗时172ms

const

maxn=100;

var

map:array [1..maxn,1..2] of longint;

h:array [1..2] of longint;

n,i,j,t,w,k,m,g:longint;

begin

read(n,m);

for i:=1 to m do

begin

read(map[i,1],map[i,2]);

if map[i,1]>map[i,2] then

begin

g:=map[i,1];

map[i,1]:=map[i,2];

map[i,2]:=g;

end;

end;

for i:=1 to m-1 do

for j:=i+1 to m do

begin

if map[i,1]>map[j,1] then

begin

h:=map[i];

map[i]:=map[j];

map[j]:=h;

end;

end;

inc(n);

i:=1;

while m>=i do

begin

j:=i+1;

k:=0;

t:=map[i,1];

w:=map[i,2];

while (map[j,1]<=w) and (j<m) do

begin

if map[j,2]>w then w:=map[j,2];

inc(j);

k:=1;

end;

dec(n,w-t+1);

if k=1 then i:=j+1

else i:=j;

end;

writeln(n);

end.

查看更多回复
提交回复