結果

問題 No.647 明太子
コンテスト
ユーザー shinwisteria
提出日時 2018-03-06 19:25:44
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 295 ms / 4,500 ms
コード長 857 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,845 ms
コンパイル使用メモリ 81,964 KB
実行使用メモリ 56,068 KB
最終ジャッジ日時 2026-03-14 05:53:58
合計ジャッジ時間 6,695 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

package m.shin;
import java.util.Scanner;
public class Con647 {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[][] ab = new int[N][2];
		for(int i = 0;i < N;i++){
			ab[i][0] = s.nextInt();
			ab[i][1] = s.nextInt();
		}
		int M = s.nextInt();
		int[] count = new int[M];
		for(int i = 0;i < M;i++){
			int x = s.nextInt() , y = s.nextInt();
			for(int j = 0;j < N;j++){
				if(ab[j][0] >= x && ab[j][1] <= y){
					count[i]++;
				}
			}
		}
		s.close();

		N = 0;
		for(int i = 0;i < 2;i++){
			for(int j = 0;j < M;j++){
				if(i == 0){
					if(count[j] >= count[N]){
						N = j;
					}
				}else{
					if(count[j] ==count[N] && count[N] != 0){
						System.out.println(j+1);
					}else if(count[N] == 0){
						System.out.println(0);
						break;    //未完成
					}
				}
			}
		}
	}

}
0