結果

問題 No.216 FAC
ユーザー YamaKasaYamaKasa
提出日時 2018-04-30 00:33:15
言語 Java19
(openjdk 21)
結果
AC  
実行時間 144 ms / 1,000 ms
コード長 795 bytes
コンパイル時間 2,206 ms
コンパイル使用メモリ 74,528 KB
実行使用メモリ 56,100 KB
最終ジャッジ日時 2023-09-10 08:16:21
合計ジャッジ時間 6,973 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,780 KB
testcase_01 AC 122 ms
55,972 KB
testcase_02 AC 120 ms
56,100 KB
testcase_03 AC 135 ms
55,740 KB
testcase_04 AC 128 ms
55,348 KB
testcase_05 AC 128 ms
55,836 KB
testcase_06 AC 121 ms
55,484 KB
testcase_07 AC 122 ms
55,744 KB
testcase_08 AC 119 ms
55,516 KB
testcase_09 AC 119 ms
56,000 KB
testcase_10 AC 123 ms
55,524 KB
testcase_11 AC 120 ms
55,280 KB
testcase_12 AC 120 ms
55,964 KB
testcase_13 AC 119 ms
55,304 KB
testcase_14 AC 120 ms
55,888 KB
testcase_15 AC 121 ms
55,376 KB
testcase_16 AC 139 ms
55,276 KB
testcase_17 AC 136 ms
55,520 KB
testcase_18 AC 134 ms
55,520 KB
testcase_19 AC 142 ms
55,472 KB
testcase_20 AC 144 ms
55,844 KB
testcase_21 AC 136 ms
54,408 KB
testcase_22 AC 135 ms
55,660 KB
testcase_23 AC 135 ms
55,816 KB
testcase_24 AC 138 ms
55,524 KB
testcase_25 AC 136 ms
55,776 KB
testcase_26 AC 120 ms
55,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int []a = new int[N];
		int []b = new int[N];
		for(int i = 0; i < N; i++) {
			a[i] = scan.nextInt();
		}
		for(int i = 0; i < N; i++) {
			b[i] = scan.nextInt();
		}
		scan.close();
		HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
		int k = 0;
		for(int i = 0; i < N; i++) {
			if(b[i] == 0) {
				k += a[i];
			}else {
				if(map.get(b[i]) != null) {
					map.put(b[i], map.get(b[i]) + a[i]);
				}else {
					map.put(b[i], a[i]);
				}
			}
		}
		for(int t : map.keySet()) {
			if(k < map.get(t)) {
				System.out.println("NO");
				System.exit(0);
			}
		}
		System.out.println("YES");
	}
}
0