import java.util.Scanner;
public class _1083 {
public static final int MAX = 400;
public static void main(String[] args) {
int from, to, max_time;
int times[] = new int[MAX + 1];
Scanner sc = new Scanner(System.in);
int count = sc.nextInt();
while (count-->0) {
for (int j = 1; j <= MAX; j++)
times[j] = 0;
int num = sc.nextInt();
int i = 0, tmp;
while (i++ < num) {
from = sc.nextInt();
to = sc.nextInt();
if (from > to) {
tmp = from;
from = to;
to = tmp;
}
if ((from & 1) == 0)
from--;
if ((to & 1) != 0)
to++;
for (int j = from; j <= to; j++)
times[j]++;
}
max_time = times[1];
for (int j = 2; j <= MAX; j++) {
if (times[j] > max_time)
max_time = times[j];
}
System.out.println(max_time * 10);
}
}
}
小结:
1.不要求得到具体搬运决策而只需知道总时间,用一个走廊次数的数组表明使用情况,最终的时间就是次数的最大值*10分钟;
2.将from>to规约到from<to的情形;
3.对偶数from和奇数to的特殊处理方式(在这里考虑的是例如1,2;3,4和2,3;4,5不同的情况)。