結果

問題 No.647 明太子
ユーザー tetsutetsu
提出日時 2018-02-09 22:50:07
言語 Java19
(openjdk 21)
結果
AC  
実行時間 434 ms / 4,500 ms
コード長 827 bytes
コンパイル時間 3,802 ms
コンパイル使用メモリ 74,556 KB
実行使用メモリ 60,680 KB
最終ジャッジ日時 2023-09-09 09:25:11
合計ジャッジ時間 10,381 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,872 KB
testcase_01 AC 125 ms
56,168 KB
testcase_02 AC 125 ms
56,076 KB
testcase_03 AC 125 ms
55,952 KB
testcase_04 AC 131 ms
55,940 KB
testcase_05 AC 131 ms
55,748 KB
testcase_06 AC 130 ms
55,940 KB
testcase_07 AC 133 ms
56,180 KB
testcase_08 AC 129 ms
56,252 KB
testcase_09 AC 187 ms
58,504 KB
testcase_10 AC 197 ms
58,452 KB
testcase_11 AC 182 ms
56,508 KB
testcase_12 AC 192 ms
59,064 KB
testcase_13 AC 202 ms
58,940 KB
testcase_14 AC 387 ms
60,372 KB
testcase_15 AC 224 ms
59,544 KB
testcase_16 AC 196 ms
58,952 KB
testcase_17 AC 393 ms
60,540 KB
testcase_18 AC 400 ms
60,680 KB
testcase_19 AC 317 ms
60,148 KB
testcase_20 AC 306 ms
60,240 KB
testcase_21 AC 233 ms
59,688 KB
testcase_22 AC 434 ms
60,380 KB
testcase_23 AC 168 ms
56,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yuki183;

import java.util.Scanner;

public class B {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		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[] cnt = new int[m];
		for(int i=0; i<n; i++) {
			for(int j=0; j<m; j++) {
				if(x[j]<=a[i]&&b[i]<=y[j]) cnt[j]++;
			}
		}
		int max = -1;
		for(int i=0; i<m; i++) {
			max = Math.max(max, cnt[i]);
		}
		if(max==0) {
			System.out.println(0); return;
		}
		for(int i=0; i<m; i++) {
			if(max==cnt[i]) System.out.println(i+1);
		}
	}

}
0