結果

問題 No.647 明太子
ユーザー GrenacheGrenache
提出日時 2018-02-09 22:29:57
言語 Java19
(openjdk 21)
結果
AC  
実行時間 426 ms / 4,500 ms
コード長 1,148 bytes
コンパイル時間 3,275 ms
コンパイル使用メモリ 74,900 KB
実行使用メモリ 60,628 KB
最終ジャッジ日時 2023-09-09 09:22:13
合計ジャッジ時間 9,382 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
56,124 KB
testcase_01 AC 119 ms
56,064 KB
testcase_02 AC 116 ms
56,156 KB
testcase_03 AC 121 ms
55,708 KB
testcase_04 AC 125 ms
56,356 KB
testcase_05 AC 122 ms
55,832 KB
testcase_06 AC 123 ms
56,028 KB
testcase_07 AC 136 ms
56,240 KB
testcase_08 AC 129 ms
56,068 KB
testcase_09 AC 191 ms
58,392 KB
testcase_10 AC 198 ms
58,576 KB
testcase_11 AC 170 ms
56,336 KB
testcase_12 AC 197 ms
58,588 KB
testcase_13 AC 202 ms
59,136 KB
testcase_14 AC 368 ms
60,288 KB
testcase_15 AC 230 ms
59,916 KB
testcase_16 AC 197 ms
56,544 KB
testcase_17 AC 393 ms
60,628 KB
testcase_18 AC 413 ms
60,172 KB
testcase_19 AC 334 ms
60,008 KB
testcase_20 AC 313 ms
60,488 KB
testcase_21 AC 239 ms
60,292 KB
testcase_22 AC 426 ms
60,464 KB
testcase_23 AC 180 ms
56,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder647 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		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];
		int max = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (x[j] <= a[i] && y[j] >= b[i]) {
					cnt[j]++;
					max = Math.max(max, cnt[j]);
				}
			}
		}

		if (max == 0) {
			pr.println(0);
		} else {
			for (int i = 0; i < m; i++) {
				if (cnt[i] == max) {
					pr.println(i + 1);
				}
			}
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0