結果

問題 No.647 明太子
ユーザー Grenache
提出日時 2018-02-09 22:29:57
言語 Java
(openjdk 23)
結果
AC  
実行時間 475 ms / 4,500 ms
コード長 1,148 bytes
コンパイル時間 3,330 ms
コンパイル使用メモリ 77,696 KB
実行使用メモリ 59,236 KB
最終ジャッジ日時 2024-06-27 02:29:19
合計ジャッジ時間 9,910 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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