結果
| 問題 | 
                            No.216 FAC
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2015-06-10 22:25:18 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 154 ms / 1,000 ms | 
| コード長 | 736 bytes | 
| コンパイル時間 | 3,534 ms | 
| コンパイル使用メモリ | 77,292 KB | 
| 実行使用メモリ | 41,876 KB | 
| 最終ジャッジ日時 | 2024-10-15 00:38:40 | 
| 合計ジャッジ時間 | 8,297 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 24 | 
ソースコード
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[100];
		for(int i = 0;i<n;i++){
			score[i] = sc.nextInt();
		}
		for(int i = 0;i<n;i++){
			flag[i] = sc.nextInt();
		}
		for(int i = 0;i<100;i++){
			others[i] = 0;
		}
		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<100;i++){
			if(res < others[i]){
				win = 1;
				break;
			}
		}
		if(win == 1){
			System.out.println("NO");
		}else{
			System.out.println("YES");
		}
	}
}