比赛 |
模拟测试2 |
评测结果 |
AWWWWWEEEE |
题目名称 |
火车调度 |
最终得分 |
10 |
用户昵称 |
wangwangdog |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-10-12 20:50:23 |
显示代码纯文本
program exer1;
var
aa,bb,cc,i,j,tt,pp,qq,rr,ll,trainnum,trainstay:integer;
trainname:array[1..60]of integer;
start:array[1..60]of integer;
go:array[1..60]of integer;
d:array[1..60,1..3]of integer;
f:text;
function search(ll:integer;time:integer):integer;
var
kk:integer;
ss:integer;
begin
ss:=0;
kk:=ll;
while d[kk,2]<>0 do
begin
if go[kk]>=time then ss:=ss+1;
kk:=d[kk,2];
end;
if go[kk]>=time then ss:=ss+1;
search:=ss;
end;
begin
assign(f,'train.in');
reset(f);
readln(f,trainnum,trainstay);
for i:=1 to trainnum do
readln(f,start[i],go[i]);
close(f);
assign(f,'train.out');
rewrite(f);
for i:=1 to trainnum do
for j:=1 to trainnum-1 do
if start[j]>start[j+1]
then
begin
aa:=trainname[j];
bb:=start[j];
cc:=go[j];
trainname[j]:=trainname[j+1];
start[j]:=start[j+1];
go[j]:=go[j+1];
go[j+1]:=cc;
start[j+1]:=bb;
trainname[j+1]:=aa;
end;
d[1,1]:=trainname[1];
d[1,2]:=0;
d[1,3]:=1;
for i:=2 to trainnum do
begin
pp:=0;
for j:=1 to i-1 do
begin
if
(go[i]>=go[j])and
(search(j,start[i])+1<=trainstay)and
(d[j,3]>pp)
then
begin
pp:=d[j,3];
tt:=j;
end;
end;{j}
if pp=0 then begin d[i,1]:=trainname[i];d[i,2]:=0;d[i,3]:=1;end
else
begin
d[i,1]:=trainname[i];
d[i,2]:=tt;
d[i,3]:=pp+1;
end;
end;{i}
pp:=0;
for i:=1 to trainnum do
if d[i,3]>pp then pp:=d[i,3];
writeln(f,pp);
close(f);
end.