結果

問題 No.216 FAC
ユーザー kohaku_kohaku
提出日時 2016-11-13 06:58:41
言語 Java
(openjdk 23)
結果
AC  
実行時間 132 ms / 1,000 ms
コード長 773 bytes
コンパイル時間 1,936 ms
コンパイル使用メモリ 75,084 KB
実行使用メモリ 42,000 KB
最終ジャッジ日時 2024-11-25 21:47:35
合計ジャッジ時間 6,039 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

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