比赛 NOIP_2 评测结果 WWWAWWWWWW
题目名称 到天宫做客 最终得分 10
用户昵称 lc 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-09-08 21:25:54
显示代码纯文本
program day2_1;
 const
  month:array[1..12] of integer=(31,29,31,30,31,30,31,31,30,31,30,31);
 var
     tmp,ans:real;
     a,b:array[1..365] of integer;
     n,i,j:integer;

 procedure swap(var a,b:integer);
  var
      temp:integer;
  begin
   temp:=a;
   a:=b;
   b:=temp
  end;

 function suan(a1,b1,a2,b2:integer):real;

  var
     i,tmp:integer;
  begin
   if (a1>a2) or (a1=a2) and (b1-b2>-2) then exit(0);
   if a1=a2
   then exit(b2-b1-1)
   else
       begin
       tmp:=month[a1]-b1;
       for i:=a1+1 to a2-1 do
       inc(tmp,month[i]);
       inc(tmp,b2-1);
       exit(tmp);
       end;
  end;

 begin
  assign(input,'heaven.in');
  assign(output,'heaven.out');
  reset(input); rewrite(output);
  read(n);
  for i:=1 to n do
  read(a[i],b[i]);
  for i:=1 to n-1 do
   for j:=i+1 to n do
   if (a[i]>a[j]) or (a[i]=a[j]) and (b[i]>b[j])
   then
       begin
       swap(a[i],a[j]);
       swap(b[i],b[j]);
       end;
 for i:=1 to n-1 do
  begin
  tmp:=suan(a[i],b[i],a[j],b[j]);
  if tmp>ans
  then ans:=tmp
  end;
 tmp:=suan(a[n],b[n],12,31)+suan(1,1,a[1],b[1])+2;
 if tmp>ans then ans:=tmp;
 writeln(ans/366*24*3600:0:0);
 close(input); close(output);
end.