結果
問題 | No.216 FAC |
ユーザー |
![]() |
提出日時 | 2018-04-30 00:33:15 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 156 ms / 1,000 ms |
コード長 | 795 bytes |
コンパイル時間 | 2,348 ms |
コンパイル使用メモリ | 77,600 KB |
実行使用メモリ | 41,928 KB |
最終ジャッジ日時 | 2024-06-27 23:45:21 |
合計ジャッジ時間 | 7,028 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
import java.util.HashMap;import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner scan = new Scanner(System.in);int N = scan.nextInt();int []a = new int[N];int []b = new int[N];for(int i = 0; i < N; i++) {a[i] = scan.nextInt();}for(int i = 0; i < N; i++) {b[i] = scan.nextInt();}scan.close();HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();int k = 0;for(int i = 0; i < N; i++) {if(b[i] == 0) {k += a[i];}else {if(map.get(b[i]) != null) {map.put(b[i], map.get(b[i]) + a[i]);}else {map.put(b[i], a[i]);}}}for(int t : map.keySet()) {if(k < map.get(t)) {System.out.println("NO");System.exit(0);}}System.out.println("YES");}}