結果

問題 No.216 FAC
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-13 06:58:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 138 ms / 1,000 ms
コード長 773 bytes
コンパイル時間 1,957 ms
コンパイル使用メモリ 74,348 KB
実行使用メモリ 41,748 KB
最終ジャッジ日時 2024-05-04 11:17:13
合計ジャッジ時間 6,176 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
40,256 KB
testcase_01 AC 110 ms
40,996 KB
testcase_02 AC 111 ms
41,396 KB
testcase_03 AC 131 ms
40,960 KB
testcase_04 AC 131 ms
41,552 KB
testcase_05 AC 121 ms
41,564 KB
testcase_06 AC 100 ms
40,080 KB
testcase_07 AC 110 ms
41,376 KB
testcase_08 AC 112 ms
41,400 KB
testcase_09 AC 115 ms
41,424 KB
testcase_10 AC 103 ms
40,072 KB
testcase_11 AC 100 ms
39,948 KB
testcase_12 AC 110 ms
41,012 KB
testcase_13 AC 112 ms
41,016 KB
testcase_14 AC 94 ms
39,944 KB
testcase_15 AC 111 ms
41,356 KB
testcase_16 AC 123 ms
41,596 KB
testcase_17 AC 124 ms
41,488 KB
testcase_18 AC 129 ms
41,488 KB
testcase_19 AC 131 ms
41,496 KB
testcase_20 AC 135 ms
41,528 KB
testcase_21 AC 132 ms
41,748 KB
testcase_22 AC 127 ms
40,984 KB
testcase_23 AC 128 ms
41,592 KB
testcase_24 AC 126 ms
41,652 KB
testcase_25 AC 138 ms
41,696 KB
testcase_26 AC 117 ms
40,988 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