結果

問題 No.647 明太子
ユーザー ほっしいーほっしいー
提出日時 2018-02-10 16:54:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 422 ms / 4,500 ms
コード長 851 bytes
コンパイル時間 4,201 ms
コンパイル使用メモリ 74,100 KB
実行使用メモリ 61,120 KB
最終ジャッジ日時 2023-09-09 09:31:09
合計ジャッジ時間 9,977 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
55,676 KB
testcase_01 AC 112 ms
55,856 KB
testcase_02 AC 114 ms
55,876 KB
testcase_03 AC 115 ms
55,728 KB
testcase_04 AC 119 ms
55,524 KB
testcase_05 AC 116 ms
55,888 KB
testcase_06 AC 115 ms
55,544 KB
testcase_07 AC 120 ms
54,044 KB
testcase_08 AC 121 ms
56,376 KB
testcase_09 AC 169 ms
56,524 KB
testcase_10 AC 174 ms
56,888 KB
testcase_11 AC 164 ms
56,116 KB
testcase_12 AC 170 ms
56,340 KB
testcase_13 AC 183 ms
58,820 KB
testcase_14 AC 352 ms
60,532 KB
testcase_15 AC 197 ms
58,740 KB
testcase_16 AC 171 ms
56,176 KB
testcase_17 AC 367 ms
58,776 KB
testcase_18 AC 373 ms
60,752 KB
testcase_19 AC 256 ms
60,168 KB
testcase_20 AC 248 ms
60,032 KB
testcase_21 AC 203 ms
59,000 KB
testcase_22 AC 422 ms
61,120 KB
testcase_23 AC 157 ms
56,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class 明太子 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n =Integer.parseInt(sc.next(),10);
		int[][] x=new int[n][2];
		for(int i=0;i<n;i++) {
			x[i][0]=Integer.parseInt(sc.next(),10);
			x[i][1]=Integer.parseInt(sc.next(),10);
		}
		int m= Integer.parseInt(sc.next(),10);
		int[][] y=new int[m][2];
		for(int i=0;i<m;i++) {
			y[i][0]=Integer.parseInt(sc.next(),10);
			y[i][1]=Integer.parseInt(sc.next(),10);
		}
		
		int[] z=new int[m];
		for(int i=0;i<m;i++) {
			z[i]=0;
			for(int j=0;j<n;j++) 
				if((x[j][0]>=y[i][0])&&(x[j][1]<=y[i][1]))
					z[i]++;
		}
		int max=0;
		for(int i=0;i<m;i++) {
			if(max<z[i])
				max=z[i];
		}
		if(max!=0) {
		for(int i=0;i<m;i++) 
			if(max==z[i])
				System.out.println(i+1);
		}else{
			System.out.println(0);
		}
	}

}
0