結果

問題 No.647 明太子
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-13 22:42:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 461 ms / 4,500 ms
コード長 853 bytes
コンパイル時間 2,013 ms
コンパイル使用メモリ 74,508 KB
実行使用メモリ 60,904 KB
最終ジャッジ日時 2023-09-09 09:34:08
合計ジャッジ時間 8,473 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,704 KB
testcase_01 AC 123 ms
55,960 KB
testcase_02 AC 123 ms
55,752 KB
testcase_03 AC 126 ms
56,016 KB
testcase_04 AC 127 ms
55,840 KB
testcase_05 AC 128 ms
55,856 KB
testcase_06 AC 126 ms
55,848 KB
testcase_07 AC 139 ms
55,960 KB
testcase_08 AC 139 ms
55,864 KB
testcase_09 AC 196 ms
58,796 KB
testcase_10 AC 205 ms
58,932 KB
testcase_11 AC 186 ms
56,296 KB
testcase_12 AC 203 ms
59,040 KB
testcase_13 AC 214 ms
59,236 KB
testcase_14 AC 377 ms
60,508 KB
testcase_15 AC 234 ms
59,888 KB
testcase_16 AC 203 ms
58,880 KB
testcase_17 AC 404 ms
60,796 KB
testcase_18 AC 417 ms
60,904 KB
testcase_19 AC 338 ms
60,168 KB
testcase_20 AC 314 ms
59,840 KB
testcase_21 AC 246 ms
60,220 KB
testcase_22 AC 461 ms
60,752 KB
testcase_23 AC 190 ms
56,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] wallet = new int[n];
		int[] favorite = new int[n];
		for (int i=0; i<n; i++) {
			wallet[i] = sc.nextInt();
			favorite[i] = sc.nextInt();
		}

		int m = sc.nextInt();
		int[] price = new int[m];
		int[] spicy = new int[m];
		for (int i=0; i<m; i++) {
			price[i] = sc.nextInt();
			spicy[i] = sc.nextInt();
		}

		int[] miracle = new int[m];
		int best = -1;
		for (int i=0; i<n; i++) {
			for (int j=0; j<m; j++) {
				if (wallet[i]>=price[j] && favorite[i]<=spicy[j]) {
					miracle[j]++;
					best = Math.max(best,miracle[j]);
				}
			}
		}

		if (best==-1) {System.out.println(0);}
		else {
			for (int i=0; i<m; i++) {
				if (miracle[i]==best) {System.out.println(i+1);}
			}
		}
	}
}
0