結果

問題 No.216 FAC
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-13 06:58:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 143 ms / 1,000 ms
コード長 773 bytes
コンパイル時間 2,129 ms
コンパイル使用メモリ 71,300 KB
実行使用メモリ 56,552 KB
最終ジャッジ日時 2023-08-17 04:10:13
合計ジャッジ時間 6,816 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,892 KB
testcase_01 AC 121 ms
56,176 KB
testcase_02 AC 122 ms
56,236 KB
testcase_03 AC 137 ms
55,952 KB
testcase_04 AC 130 ms
56,092 KB
testcase_05 AC 127 ms
55,852 KB
testcase_06 AC 120 ms
55,924 KB
testcase_07 AC 122 ms
55,704 KB
testcase_08 AC 121 ms
55,944 KB
testcase_09 AC 128 ms
55,784 KB
testcase_10 AC 131 ms
55,456 KB
testcase_11 AC 120 ms
55,884 KB
testcase_12 AC 122 ms
56,452 KB
testcase_13 AC 120 ms
55,788 KB
testcase_14 AC 121 ms
56,044 KB
testcase_15 AC 125 ms
55,644 KB
testcase_16 AC 143 ms
55,612 KB
testcase_17 AC 139 ms
55,716 KB
testcase_18 AC 140 ms
56,472 KB
testcase_19 AC 137 ms
56,308 KB
testcase_20 AC 137 ms
55,692 KB
testcase_21 AC 139 ms
56,552 KB
testcase_22 AC 139 ms
55,744 KB
testcase_23 AC 137 ms
55,816 KB
testcase_24 AC 137 ms
55,692 KB
testcase_25 AC 137 ms
55,648 KB
testcase_26 AC 120 ms
55,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] a = new int [N];
        int [] b = new int [N];
        int [] score = new int [100];
        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
        }
        int sum=0;
        int max=0;
        for(int i=0; i<N; i++){
            b[i] = sc.nextInt();
            if(b[i]==0){
                sum=sum+a[i];
            }else{
                score[b[i]-1] = score[b[i]-1] + a[i];
                max=Math.max(max,score[b[i]-1]);
            }
        }
        if(sum>=max){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}
0