結果

問題 No.216 FAC
ユーザー YamaKasaYamaKasa
提出日時 2018-04-30 00:23:04
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 787 bytes
コンパイル時間 2,431 ms
コンパイル使用メモリ 78,416 KB
実行使用メモリ 57,972 KB
最終ジャッジ日時 2023-09-10 08:16:08
合計ジャッジ時間 7,491 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,256 KB
testcase_01 AC 124 ms
55,640 KB
testcase_02 AC 122 ms
55,856 KB
testcase_03 AC 138 ms
55,060 KB
testcase_04 AC 130 ms
55,128 KB
testcase_05 AC 130 ms
55,216 KB
testcase_06 AC 125 ms
55,508 KB
testcase_07 AC 123 ms
55,572 KB
testcase_08 AC 125 ms
55,712 KB
testcase_09 AC 125 ms
55,908 KB
testcase_10 AC 126 ms
55,972 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 123 ms
55,700 KB
testcase_14 WA -
testcase_15 AC 122 ms
55,020 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 139 ms
55,720 KB
testcase_19 AC 143 ms
55,352 KB
testcase_20 AC 139 ms
55,776 KB
testcase_21 AC 141 ms
55,308 KB
testcase_22 AC 140 ms
55,368 KB
testcase_23 AC 140 ms
55,300 KB
testcase_24 AC 141 ms
55,564 KB
testcase_25 AC 141 ms
54,996 KB
testcase_26 AC 124 ms
55,684 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 < t) {
				System.out.println("NO");
				System.exit(0);
			}
		}
		System.out.println("YES");
	}
}
0