pku1083 Moving Tables
最大的移动时间取决于被经过次数最多的一个房间,把每个移动看做一个区间,覆盖1-400的点,特别的,有时区间端点需要加减,因为它会影响后面一个点(前面一个点)。
View Code
1 program pku1083(input,output); 2 var 3 cover:array[0..801] of integer; 4 x,y,n:longint; 5 cases:longint; 6 i,j:longint; 7 answer:longint; 8 procedure swap(var aa,bb:longint); 9 var 10 tt:longint; 11 begin 12 tt:=aa; 13 aa:=bb; 14 bb:=tt; 15 end; 16 begin 17 readln(cases); 18 while cases>0 do 19 begin 20 dec(cases); 21 fillchar(cover,sizeof(cover),0); 22 readln(n); 23 for i:=1 to n do 24 begin 25 readln(x,y); 26 if x>y then 27 swap(x,y); 28 if not odd(x) then 29 dec(x); 30 if odd(y) then 31 inc(y); 32 for j:=x to y do 33 inc(cover[j]); 34 end; 35 answer:=0; 36 for i:=1 to 800 do 37 if cover[i]>answer then 38 answer:=cover[i]; 39 writeln(answer*10); 40 end; 41 end.