結果

問題 No.216 FAC
ユーザー yagi2yagi2
提出日時 2017-04-21 12:37:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 1,000 ms
コード長 1,123 bytes
コンパイル時間 1,974 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 56,476 KB
最終ジャッジ日時 2023-09-27 10:52:19
合計ジャッジ時間 6,437 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
56,092 KB
testcase_01 AC 115 ms
56,188 KB
testcase_02 AC 116 ms
56,004 KB
testcase_03 AC 117 ms
55,864 KB
testcase_04 AC 120 ms
56,244 KB
testcase_05 AC 117 ms
55,964 KB
testcase_06 AC 112 ms
56,344 KB
testcase_07 AC 112 ms
55,976 KB
testcase_08 AC 112 ms
55,748 KB
testcase_09 AC 111 ms
56,260 KB
testcase_10 AC 113 ms
56,268 KB
testcase_11 AC 111 ms
56,188 KB
testcase_12 AC 115 ms
55,868 KB
testcase_13 AC 111 ms
55,640 KB
testcase_14 AC 111 ms
56,424 KB
testcase_15 AC 110 ms
55,948 KB
testcase_16 AC 120 ms
56,476 KB
testcase_17 AC 121 ms
56,460 KB
testcase_18 AC 118 ms
56,080 KB
testcase_19 AC 120 ms
55,584 KB
testcase_20 AC 122 ms
55,824 KB
testcase_21 AC 119 ms
54,240 KB
testcase_22 AC 123 ms
55,956 KB
testcase_23 AC 121 ms
55,836 KB
testcase_24 AC 121 ms
55,840 KB
testcase_25 AC 120 ms
55,948 KB
testcase_26 AC 110 ms
55,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        int[][] scores = new int[N][2];

        for (int i = 0; i < N; i++) {
            scores[i][0] = Integer.parseInt(sc.next());
        }


        Map<Integer, Integer> map = new HashMap<>();

        for (int i = 0; i < N; i++) {
            int p = Integer.parseInt(sc.next());

            if (p == 0) {
                scores[i][1] = 0;
                continue;
            }

            if (!map.containsKey(p)) map.put(p, 0);
            map.put(p, map.get(p) + scores[i][0]);
            scores[i][1] = p;
        }

        int K = 0;
        for (int i = 0; i < N; i++) {
            if (scores[i][1] == 0) {
                K += scores[i][0];
            }
        }

        final int[] max = {-1};
        map.values().forEach(integer -> {
            if (max[0] < integer) max[0] = integer;
        });

        System.out.println((max[0] <= K)? "YES" : "NO");
    }
}
0