結果

問題 No.216 FAC
ユーザー 練習生練習生
提出日時 2015-08-18 08:20:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 153 ms / 1,000 ms
コード長 905 bytes
コンパイル時間 3,493 ms
コンパイル使用メモリ 75,156 KB
実行使用メモリ 41,976 KB
最終ジャッジ日時 2024-04-23 01:27:08
合計ジャッジ時間 8,227 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
41,296 KB
testcase_01 AC 134 ms
41,384 KB
testcase_02 AC 133 ms
41,896 KB
testcase_03 AC 143 ms
41,508 KB
testcase_04 AC 136 ms
41,440 KB
testcase_05 AC 136 ms
41,312 KB
testcase_06 AC 132 ms
41,492 KB
testcase_07 AC 132 ms
41,168 KB
testcase_08 AC 136 ms
41,440 KB
testcase_09 AC 131 ms
41,264 KB
testcase_10 AC 136 ms
41,452 KB
testcase_11 AC 128 ms
41,428 KB
testcase_12 AC 131 ms
41,608 KB
testcase_13 AC 132 ms
41,296 KB
testcase_14 AC 131 ms
41,640 KB
testcase_15 AC 134 ms
41,252 KB
testcase_16 AC 149 ms
41,456 KB
testcase_17 AC 145 ms
41,628 KB
testcase_18 AC 146 ms
41,976 KB
testcase_19 AC 150 ms
41,596 KB
testcase_20 AC 142 ms
41,356 KB
testcase_21 AC 149 ms
41,880 KB
testcase_22 AC 150 ms
41,908 KB
testcase_23 AC 153 ms
41,964 KB
testcase_24 AC 149 ms
41,560 KB
testcase_25 AC 143 ms
41,592 KB
testcase_26 AC 132 ms
41,328 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