結果

問題 No.647 明太子
ユーザー ohagi_1182ohagi_1182
提出日時 2018-02-24 18:46:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 434 ms / 4,500 ms
コード長 867 bytes
コンパイル時間 3,896 ms
コンパイル使用メモリ 73,516 KB
実行使用メモリ 62,468 KB
最終ジャッジ日時 2023-09-09 09:36:05
合計ジャッジ時間 8,503 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,884 KB
testcase_01 AC 123 ms
55,652 KB
testcase_02 AC 123 ms
55,948 KB
testcase_03 AC 121 ms
55,872 KB
testcase_04 AC 129 ms
55,736 KB
testcase_05 AC 127 ms
55,944 KB
testcase_06 AC 127 ms
55,604 KB
testcase_07 AC 141 ms
55,716 KB
testcase_08 AC 137 ms
55,688 KB
testcase_09 AC 193 ms
58,992 KB
testcase_10 AC 199 ms
58,796 KB
testcase_11 AC 189 ms
55,756 KB
testcase_12 AC 197 ms
58,536 KB
testcase_13 AC 210 ms
59,220 KB
testcase_14 AC 397 ms
60,396 KB
testcase_15 AC 231 ms
59,136 KB
testcase_16 AC 201 ms
58,508 KB
testcase_17 AC 401 ms
62,468 KB
testcase_18 AC 414 ms
60,320 KB
testcase_19 AC 320 ms
60,844 KB
testcase_20 AC 307 ms
60,308 KB
testcase_21 AC 240 ms
59,200 KB
testcase_22 AC 434 ms
60,484 KB
testcase_23 AC 180 ms
55,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		int m = sc.nextInt();
		int[] x = new int[m];
		int[] y = new int[m];
		for(int i = 0 ; i < m ; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		int[] sum = new int[m];
		for(int i = 0 ; i < m ; i++) {
			int cnt = 0;
			for(int j = 0 ; j < n ; j++) {
				if(a[j] >= x[i] && b[j] <= y[i]) cnt++;
			}
			sum[i] = cnt;
		}
		int max = -1;
		for(int i = 0 ; i < m ; i++) {
			max = Math.max(max, sum[i]);
		}
		if(max == 0) {
			System.out.println(0);
			return;
		}
		for(int i = 0 ; i < m ; i++) {
			if(sum[i] == max) {
				System.out.println(i + 1);
			}
		}
	}

}
0