結果

問題 No.216 FAC
ユーザー k_kadorak_kadora
提出日時 2015-06-10 22:25:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 160 ms / 1,000 ms
コード長 736 bytes
コンパイル時間 3,571 ms
コンパイル使用メモリ 77,940 KB
実行使用メモリ 41,908 KB
最終ジャッジ日時 2024-04-23 01:24:32
合計ジャッジ時間 8,379 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
41,644 KB
testcase_01 AC 135 ms
41,488 KB
testcase_02 AC 133 ms
41,496 KB
testcase_03 AC 147 ms
41,576 KB
testcase_04 AC 142 ms
41,480 KB
testcase_05 AC 137 ms
41,364 KB
testcase_06 AC 134 ms
41,340 KB
testcase_07 AC 133 ms
41,356 KB
testcase_08 AC 135 ms
41,476 KB
testcase_09 AC 134 ms
41,456 KB
testcase_10 AC 135 ms
41,292 KB
testcase_11 AC 135 ms
41,432 KB
testcase_12 AC 135 ms
41,516 KB
testcase_13 AC 133 ms
41,200 KB
testcase_14 AC 135 ms
41,588 KB
testcase_15 AC 135 ms
41,316 KB
testcase_16 AC 149 ms
41,552 KB
testcase_17 AC 152 ms
41,404 KB
testcase_18 AC 151 ms
41,688 KB
testcase_19 AC 153 ms
41,808 KB
testcase_20 AC 149 ms
41,712 KB
testcase_21 AC 147 ms
41,544 KB
testcase_22 AC 150 ms
41,544 KB
testcase_23 AC 153 ms
41,744 KB
testcase_24 AC 150 ms
41,732 KB
testcase_25 AC 160 ms
41,908 KB
testcase_26 AC 132 ms
41,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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");
		}
	}
}
0