結果

問題 No.216 FAC
ユーザー 練習生練習生
提出日時 2015-08-18 08:20:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 139 ms / 1,000 ms
コード長 905 bytes
コンパイル時間 3,303 ms
コンパイル使用メモリ 72,564 KB
実行使用メモリ 56,768 KB
最終ジャッジ日時 2023-08-05 02:52:40
合計ジャッジ時間 8,002 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
56,044 KB
testcase_01 AC 119 ms
55,904 KB
testcase_02 AC 119 ms
55,500 KB
testcase_03 AC 134 ms
56,424 KB
testcase_04 AC 127 ms
56,556 KB
testcase_05 AC 127 ms
55,992 KB
testcase_06 AC 121 ms
55,872 KB
testcase_07 AC 120 ms
56,312 KB
testcase_08 AC 122 ms
55,936 KB
testcase_09 AC 121 ms
56,104 KB
testcase_10 AC 121 ms
55,952 KB
testcase_11 AC 121 ms
56,456 KB
testcase_12 AC 121 ms
56,004 KB
testcase_13 AC 120 ms
56,268 KB
testcase_14 AC 120 ms
56,600 KB
testcase_15 AC 119 ms
56,108 KB
testcase_16 AC 136 ms
56,768 KB
testcase_17 AC 139 ms
53,752 KB
testcase_18 AC 136 ms
55,824 KB
testcase_19 AC 137 ms
56,240 KB
testcase_20 AC 136 ms
55,828 KB
testcase_21 AC 138 ms
56,328 KB
testcase_22 AC 138 ms
56,432 KB
testcase_23 AC 136 ms
55,940 KB
testcase_24 AC 138 ms
56,264 KB
testcase_25 AC 136 ms
56,424 KB
testcase_26 AC 118 ms
55,520 KB
権限があれば一括ダウンロードができます

ソースコード

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[100];
		// スコア一覧を配列に格納
		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 < 100; i++){
			if(answer[i] > max){
				max = answer[i];
			}
		}
		// 優勝できるか判定
		if(kScore >= max){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}
0