poj 1083
6447 ワード
1 import java.io.BufferedReader;
2 import java.io.InputStreamReader;
3 import java.util.Arrays;
4
5 public class Main {
6
7 // 200 , , , *10
8 public static void main(String[] args) throws Exception {
9 BufferedReader reader = new BufferedReader(new InputStreamReader(
10 System.in));
11 int numOfTestCase = Integer.parseInt(reader.readLine());
12 for (int i = 0; i < numOfTestCase; i++) {
13 int[] times = new int[200];
14 int numOfTables = Integer.parseInt(reader.readLine());
15 for (int j = 0; j < numOfTables; j++) {
16 String line = reader.readLine();
17 String[] nums = line.split(" ");
18 int t1 = Integer.parseInt(nums[0]);
19 int t2 = Integer.parseInt(nums[1]);
20 if(t1 > t2){
21 int tmp = t2;
22 t2 = t1;
23 t1 = tmp;
24 }
25 int s1 = 0;
26 if (t1 % 2 != 0) {
27 s1 = t1 / 2;
28 } else {
29 s1 = t1 / 2 - 1;
30 }
31 int s2 = 0;
32 if (t2 % 2 != 0) {
33 s2 = t2 / 2;
34 } else {
35 s2 = t2 / 2 - 1;
36 }
37 for (int k = s1; k <= s2; k++) {
38 times[k]++;
39 }
40 }
41 Arrays.sort(times);
42
43 System.out.println(times[199] * 10);
44 }
45 }
46 }
注意:
1.与えられたデータの中でsがtより大きいとは限らない
2.廊下を表す配列を定義し、通るたびに++、最後にsort、最大値*10