結果

問題 No.216 FAC
ユーザー matsuyoshi30matsuyoshi30
提出日時 2018-05-07 22:27:21
言語 Java19
(openjdk 21)
結果
AC  
実行時間 145 ms / 1,000 ms
コード長 727 bytes
コンパイル時間 1,961 ms
コンパイル使用メモリ 71,716 KB
実行使用メモリ 56,188 KB
最終ジャッジ日時 2023-09-10 10:58:46
合計ジャッジ時間 6,727 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
56,060 KB
testcase_01 AC 125 ms
55,700 KB
testcase_02 AC 125 ms
53,928 KB
testcase_03 AC 143 ms
55,804 KB
testcase_04 AC 132 ms
55,784 KB
testcase_05 AC 131 ms
55,748 KB
testcase_06 AC 125 ms
55,700 KB
testcase_07 AC 125 ms
55,992 KB
testcase_08 AC 125 ms
55,456 KB
testcase_09 AC 126 ms
55,964 KB
testcase_10 AC 127 ms
55,696 KB
testcase_11 AC 125 ms
55,688 KB
testcase_12 AC 122 ms
55,892 KB
testcase_13 AC 124 ms
56,076 KB
testcase_14 AC 124 ms
55,920 KB
testcase_15 AC 125 ms
55,868 KB
testcase_16 AC 141 ms
56,176 KB
testcase_17 AC 142 ms
55,752 KB
testcase_18 AC 141 ms
56,044 KB
testcase_19 AC 140 ms
55,976 KB
testcase_20 AC 140 ms
55,472 KB
testcase_21 AC 145 ms
55,476 KB
testcase_22 AC 142 ms
56,188 KB
testcase_23 AC 143 ms
56,008 KB
testcase_24 AC 144 ms
55,912 KB
testcase_25 AC 145 ms
55,628 KB
testcase_26 AC 125 ms
56,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];

        int[] c = new int[100];
        for(int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        int k_score = 0;
        for(int i = 0; i < n; i++) {
            b[i] = in.nextInt();
            if(b[i] == 0) k_score += a[i];
            else c[b[i]-1] += a[i];
        }

        String ans = "YES";
        for(int i = 0; i < 100; i++) {
            if(c[i] > k_score) {
                ans = "NO";
                break;
            }
        }
        System.out.println(ans);
    }
}
0