結果

問題 No.216 FAC
ユーザー kou6839kou6839
提出日時 2015-05-30 23:02:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 166 ms / 1,000 ms
コード長 922 bytes
コンパイル時間 2,234 ms
コンパイル使用メモリ 77,864 KB
実行使用メモリ 41,824 KB
最終ジャッジ日時 2024-04-23 01:23:40
合計ジャッジ時間 6,957 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,592 KB
testcase_01 AC 121 ms
40,128 KB
testcase_02 AC 131 ms
41,276 KB
testcase_03 AC 149 ms
41,688 KB
testcase_04 AC 140 ms
41,392 KB
testcase_05 AC 122 ms
40,104 KB
testcase_06 AC 130 ms
41,764 KB
testcase_07 AC 116 ms
40,064 KB
testcase_08 AC 135 ms
41,192 KB
testcase_09 AC 133 ms
41,340 KB
testcase_10 AC 134 ms
41,316 KB
testcase_11 AC 139 ms
41,344 KB
testcase_12 AC 134 ms
41,696 KB
testcase_13 AC 133 ms
41,212 KB
testcase_14 AC 135 ms
41,352 KB
testcase_15 AC 130 ms
41,600 KB
testcase_16 AC 146 ms
41,700 KB
testcase_17 AC 154 ms
41,592 KB
testcase_18 AC 153 ms
41,756 KB
testcase_19 AC 147 ms
41,552 KB
testcase_20 AC 153 ms
41,500 KB
testcase_21 AC 151 ms
41,596 KB
testcase_22 AC 149 ms
41,780 KB
testcase_23 AC 150 ms
41,824 KB
testcase_24 AC 166 ms
41,696 KB
testcase_25 AC 149 ms
41,808 KB
testcase_26 AC 130 ms
41,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args){
        // TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ten = 0;
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i=0;i<n;i++) a[i]=sc.nextInt();
        for(int i=0;i<n;i++) b[i]=sc.nextInt();
        HashMap<Integer, Integer> map= new HashMap<Integer, Integer>();
        for(int i=0;i<n;i++){
        	if(b[i]==0){
        		ten+=a[i];
        	}else{
        		if(map.containsKey(b[i])){
        			map.put(b[i], map.get(b[i])+a[i]);
        		}else{
        			map.put(b[i],a[i]);
        		}
        	}
        }
        for(int i:map.keySet()){
        	if(map.get(i)>ten){
        		System.out.println("NO");
        		return;
        	}
        }
        System.out.println("YES");
    }
}
0