結果
問題 |
No.216 FAC
|
ユーザー |
|
提出日時 | 2015-06-10 22:21:28 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 700 bytes |
コンパイル時間 | 2,894 ms |
コンパイル使用メモリ | 78,032 KB |
実行使用メモリ | 41,952 KB |
最終ジャッジ日時 | 2024-07-06 15:26:35 |
合計ジャッジ時間 | 6,632 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 RE * 7 |
ソースコード
import java.util.Scanner; public class Fac{ public static void main(String[] arg){ Scanner sc = new Scanner(System.in); int n,res=0,win=0; n = sc.nextInt(); int[] score = new int[n]; int[] flag = new int[n]; int[] others = new int[n]; for(int i = 0;i<n;i++){ score[i] = sc.nextInt(); others[i] = 0; } for(int i = 0;i<n;i++){ flag[i] = sc.nextInt(); } for(int i = 0;i<n;i++){ if(flag[i] == 0){ res = res + score[i]; }else{ others[flag[i]-1] = others[flag[i]-1]+score[i]; } } for(int i = 0;i<n;i++){ if(res < others[i]){ win = 1; break; } } if(win == 1){ System.out.println("NO"); }else{ System.out.println("YES"); } } }