結果

問題 No.647 明太子
ユーザー fal_rndfal_rnd
提出日時 2018-02-12 17:55:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 528 ms / 4,500 ms
コード長 798 bytes
コンパイル時間 3,353 ms
コンパイル使用メモリ 80,420 KB
実行使用メモリ 61,080 KB
最終ジャッジ日時 2023-09-09 09:33:28
合計ジャッジ時間 10,778 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
55,900 KB
testcase_01 AC 136 ms
55,832 KB
testcase_02 AC 136 ms
56,348 KB
testcase_03 AC 135 ms
56,116 KB
testcase_04 AC 140 ms
56,436 KB
testcase_05 AC 138 ms
56,192 KB
testcase_06 AC 136 ms
56,016 KB
testcase_07 AC 150 ms
55,940 KB
testcase_08 AC 153 ms
55,900 KB
testcase_09 AC 225 ms
58,948 KB
testcase_10 AC 243 ms
59,460 KB
testcase_11 AC 214 ms
56,696 KB
testcase_12 AC 230 ms
61,080 KB
testcase_13 AC 257 ms
57,924 KB
testcase_14 AC 459 ms
60,504 KB
testcase_15 AC 290 ms
60,520 KB
testcase_16 AC 236 ms
58,932 KB
testcase_17 AC 489 ms
60,496 KB
testcase_18 AC 528 ms
60,616 KB
testcase_19 AC 386 ms
60,304 KB
testcase_20 AC 391 ms
60,968 KB
testcase_21 AC 311 ms
60,564 KB
testcase_22 AC 487 ms
60,696 KB
testcase_23 AC 211 ms
56,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.util.stream.*;

class A{
	static class Person{
		int cost,hot;
		Person(int c,int h){
			this.cost=c;
			this.hot=h;
		}
		boolean isMatch(int v,int h) {
			return cost>=v&&hot<=h;
		}
	}
	public static void main(String[]$){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		Person[]p=IntStream.range(0,n)
				.mapToObj(i->new Person(s.nextInt(),s.nextInt()))
				.toArray(Person[]::new);
		int m=s.nextInt();

		ArrayList<Integer>l=new ArrayList<>();
		l.add(0);
		long max=0;
		for(int i=1;i<=m;++i) {
			int x=s.nextInt(),y=s.nextInt();
			long v=Arrays.stream(p)
					.filter(o->o.isMatch(x,y))
					.count();
			if(max<v) {
				max=v;
				l.clear();
				l.add(i);
			}else if(v>0&&max==v) {
				l.add(i);
			}
		}
		l.forEach(System.out::println);
	}
}
0