您的位置:首页 > 其它

pku1083 Moving Tables

2012-04-19 15:33 309 查看
最大的移动时间取决于被经过次数最多的一个房间,把每个移动看做一个区间,覆盖1-400的点,特别的,有时区间端点需要加减,因为它会影响后面一个点(前面一个点)。

View Code

program pku1083(input,output);
var
cover:array[0..801] of integer;
x,y,n:longint;
cases:longint;
i,j:longint;
answer:longint;
procedure swap(var aa,bb:longint);
var
tt:longint;
begin
tt:=aa;
aa:=bb;
bb:=tt;
end;
begin
readln(cases);
while cases>0 do
begin
dec(cases);
fillchar(cover,sizeof(cover),0);
readln(n);
for i:=1 to n do
begin
readln(x,y);
if x>y then
swap(x,y);
if not odd(x) then
dec(x);
if odd(y) then
inc(y);
for j:=x to y do
inc(cover[j]);
end;
answer:=0;
for i:=1 to 800 do
if cover[i]>answer then
answer:=cover[i];
writeln(answer*10);
end;
end.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: