結果

問題 No.216 FAC
ユーザー k_kadorak_kadora
提出日時 2015-06-10 22:21:28
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 700 bytes
コンパイル時間 3,110 ms
コンパイル使用メモリ 74,548 KB
実行使用メモリ 56,340 KB
最終ジャッジ日時 2023-09-20 20:38:27
合計ジャッジ時間 7,841 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,496 KB
testcase_01 AC 123 ms
56,244 KB
testcase_02 AC 122 ms
53,720 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 123 ms
56,060 KB
testcase_07 AC 121 ms
55,716 KB
testcase_08 AC 123 ms
56,120 KB
testcase_09 AC 122 ms
55,748 KB
testcase_10 AC 123 ms
56,168 KB
testcase_11 AC 125 ms
55,688 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 124 ms
55,648 KB
testcase_15 RE -
testcase_16 AC 140 ms
55,976 KB
testcase_17 AC 139 ms
56,068 KB
testcase_18 AC 139 ms
55,768 KB
testcase_19 AC 139 ms
55,912 KB
testcase_20 AC 139 ms
56,084 KB
testcase_21 AC 139 ms
55,492 KB
testcase_22 AC 139 ms
55,936 KB
testcase_23 AC 138 ms
55,748 KB
testcase_24 AC 138 ms
55,936 KB
testcase_25 AC 136 ms
55,676 KB
testcase_26 RE -
権限があれば一括ダウンロードができます

ソースコード

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