結果

問題 No.216 FAC
ユーザー 練習生練習生
提出日時 2015-08-18 08:04:05
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 901 bytes
コンパイル時間 5,904 ms
コンパイル使用メモリ 71,816 KB
実行使用メモリ 40,176 KB
最終ジャッジ日時 2023-09-25 12:46:23
合計ジャッジ時間 10,503 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
39,880 KB
testcase_01 AC 122 ms
39,636 KB
testcase_02 AC 122 ms
39,296 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 123 ms
39,616 KB
testcase_07 AC 121 ms
39,652 KB
testcase_08 AC 120 ms
39,428 KB
testcase_09 AC 122 ms
39,580 KB
testcase_10 AC 123 ms
39,608 KB
testcase_11 AC 123 ms
39,496 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 121 ms
39,556 KB
testcase_15 RE -
testcase_16 AC 141 ms
39,816 KB
testcase_17 AC 138 ms
39,832 KB
testcase_18 AC 139 ms
40,176 KB
testcase_19 AC 138 ms
39,876 KB
testcase_20 AC 134 ms
39,912 KB
testcase_21 AC 134 ms
39,936 KB
testcase_22 AC 143 ms
39,456 KB
testcase_23 AC 142 ms
39,896 KB
testcase_24 AC 138 ms
39,728 KB
testcase_25 AC 149 ms
39,604 KB
testcase_26 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No216 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int kScore = 0;
		int n = sc.nextInt();
		int[] score = new int[n];
		int[] answer = new int[n];
		// スコア一覧を配列に格納
		for(int i = 0; i < n; i++){
			score[i] = sc.nextInt();
		}
		// 解答者に得点を追加
		for(int i = 0; i < n; i++){
			int kaitou = sc.nextInt();
			if(kaitou != 0){
				// 解答者がいる場合
				kaitou--;
				answer[kaitou] += score[i];
			}else{
				// 解答者がいない場合
				kScore += score[i];
			}
		}
		sc.close();
		// k君以外の解答者で最高得点のものを検索
		int max = 0;
		for(int i = 0; i < n; i++){
			if(answer[i] > max){
				max = answer[i];
			}
		}
		// 優勝できるか判定
		if(kScore >= max){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}
0