比赛 |
NOIP_2 |
评测结果 |
AWWWWAWWWA |
题目名称 |
到天宫做客 |
最终得分 |
30 |
用户昵称 |
WaterFire |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-09-08 20:57:37 |
显示代码纯文本
program waterfire;
const
fin='heaven.in';
fout='heaven.out';
month:array[1..12] of longint=(31,29,31,30,31,30,31,31,30,31,30,31);
type
tlist = array[1..366] of longint;
var
n,s,s2,max,i,j:longint;
b: tlist;
data:array[0..366,0..366] of longint;
f,g:text;
procedure test(x,y:longint);
var
i,j:longint;
begin
for i:=1 to 12 do begin
if x=i then begin
b[s]:=b[s]+y;
exit;
end;
if x<>i then
b[s]:=b[s]+month[i];
end;
end;
procedure qsort(var a : tlist);
procedure sort(l,r: longint);
var
i,j,x,y: longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2];
repeat
while a[i]<x do
inc(i);
while x<a[j] do
dec(j);
if not(i>j) then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
j:=j-1;
end;
until i>j;
if l<j then
sort(l,j);
if i<r then
sort(i,r);
end;
begin
sort(1,max);
end;
procedure work;
var
i,j:longint;
begin
for i:=0 to n-1 do
begin
s:=b[i+1]-b[i]-1;
if s>max then max:=s;
end;
max:=round(max/366*3600*24);
end;
begin
data[0,1]:=1;data[0,2]:=1;
assign(f,fin);reset(f);
assign(g,fout);rewrite(g);
readln(f,n);
for i:=1 to n do
begin
for j:=1 to 2 do
read(f,data[i,j]);
s:=i;
test(data[i,1],data[i,2]);
end;
qsort(b);
work;
write(g,max);
close(g);
close(f);
end.