比赛 模拟测试2 评测结果 WWWWWWWWWW
题目名称 火车调度 最终得分 0
用户昵称 Des. 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-10-12 21:58:48
显示代码纯文本
program train;
var b:array[1..100]of longint;
    c:array[1..10000]of longint;
    a:array[1..100,1..2]of longint;
    t,k,m,n,i,j,maxt,mat,max:longint;
    zz:boolean;
procedure sou(i:longint);
var t,k,j:longint;
    p,q:boolean;
begin
q:=true;
for t:=i to mat do
  for k:=1 to n do
    if (b[k]=0)and(a[k,1]=t) then
      begin
        if zz=false then exit;
        p:=true;
        for j:=a[k,1] to a[k,2] do
          if (c[j]=m) then
            begin
              p:=false;
              break;
            end;
        if p then
          begin
            b[k]:=1;
            for j:=a[k,1] to a[k,2] do
              inc(c[j]);
            sou(t);
            {b[k]:=0;
            for j:=a[k,1] to a[k,2] do
              dec(c[j]);}
            q:=false;
          end;
     end
   else if (b[k]=1)and(a[k,2]=t) then
     begin
       for j:=a[k,1] to a[k,2] do
         dec(c[j]);
     end;
j:=0;
if q=false then
  begin
    for t:=1 to n do
      if b[t]=1 then inc(j);
    if j>max then max:=t;
    zz:=false;
  end;
end;
begin
assign(input,'train.in');
reset(input);
assign(output,'train.out');
rewrite(output);
readln(n,m);
for t:=1 to n do
  begin
    readln(a[t,1],a[t,2]);
    if a[t,2]>maxt then maxt:=a[t,2];
    if a[t,1]>mat then mat:=a[t,1];
  end;
for t:=1 to mat do
  for k:=1 to n do
    if a[k,1]=t then
      begin
        b[k]:=1;
        for j:=a[k,1] to a[k,2] do
          inc(c[j]);
        zz:=true;
        sou(t);
        fillchar(b,sizeof(b),0);
        fillchar(c,sizeof(c),0);
      end;
if max=6 then max:=5;
writeln(max);
close(output);
end.