結果

問題 No.216 FAC
ユーザー ffmm00ffmm00
提出日時 2015-06-01 08:34:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 162 ms / 1,000 ms
コード長 777 bytes
コンパイル時間 3,691 ms
コンパイル使用メモリ 78,060 KB
実行使用メモリ 42,140 KB
最終ジャッジ日時 2024-04-23 01:23:58
合計ジャッジ時間 8,626 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
41,176 KB
testcase_01 AC 139 ms
41,376 KB
testcase_02 AC 140 ms
41,744 KB
testcase_03 AC 150 ms
41,456 KB
testcase_04 AC 141 ms
41,840 KB
testcase_05 AC 142 ms
41,320 KB
testcase_06 AC 133 ms
41,408 KB
testcase_07 AC 139 ms
41,536 KB
testcase_08 AC 143 ms
41,452 KB
testcase_09 AC 138 ms
41,168 KB
testcase_10 AC 139 ms
41,492 KB
testcase_11 AC 141 ms
41,336 KB
testcase_12 AC 134 ms
41,356 KB
testcase_13 AC 137 ms
41,336 KB
testcase_14 AC 135 ms
41,628 KB
testcase_15 AC 141 ms
41,284 KB
testcase_16 AC 154 ms
41,584 KB
testcase_17 AC 154 ms
42,140 KB
testcase_18 AC 153 ms
41,844 KB
testcase_19 AC 157 ms
41,884 KB
testcase_20 AC 151 ms
41,844 KB
testcase_21 AC 154 ms
41,512 KB
testcase_22 AC 154 ms
41,920 KB
testcase_23 AC 152 ms
41,608 KB
testcase_24 AC 146 ms
41,628 KB
testcase_25 AC 162 ms
41,976 KB
testcase_26 AC 139 ms
41,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class N216 {

	public static void main(String[] args) {

		Scanner sca = new Scanner(System.in);
		Map<Integer, Integer> test = new HashMap<Integer, Integer>();
		int N = sca.nextInt();
		int a[] = new int[N];
		int b[] = new int[N];
		int score = 0;
		int score2 = 0;

		for (int i = 0; i < N; i++)
			a[i] = sca.nextInt();

		for (int i = 0; i < N; i++)
			b[i] = sca.nextInt();

		for (int i = 0; i < N; i++) {
			if (b[i] == 0)
				score += a[i];
			else if (test.containsKey(b[i]))
				test.put(b[i], test.get(b[i]) + a[i]);
			else
				test.put(b[i], a[i]);
		}

		for (int i : test.values())
			score2 = Math.max(score2, i);

		System.out.println((score >= score2) ? "YES" : "NO");

	}

}
0