結果

問題 No.216 FAC
ユーザー ohagi_1182ohagi_1182
提出日時 2017-10-14 16:19:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 160 ms / 1,000 ms
コード長 730 bytes
コンパイル時間 2,278 ms
コンパイル使用メモリ 77,316 KB
実行使用メモリ 42,052 KB
最終ジャッジ日時 2024-04-28 19:34:02
合計ジャッジ時間 7,217 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
41,676 KB
testcase_01 AC 134 ms
41,280 KB
testcase_02 AC 132 ms
41,220 KB
testcase_03 AC 147 ms
41,560 KB
testcase_04 AC 142 ms
41,552 KB
testcase_05 AC 140 ms
41,540 KB
testcase_06 AC 137 ms
41,076 KB
testcase_07 AC 123 ms
39,784 KB
testcase_08 AC 121 ms
39,988 KB
testcase_09 AC 138 ms
41,540 KB
testcase_10 AC 135 ms
41,348 KB
testcase_11 AC 134 ms
41,364 KB
testcase_12 AC 138 ms
41,620 KB
testcase_13 AC 137 ms
41,552 KB
testcase_14 AC 136 ms
41,568 KB
testcase_15 AC 136 ms
41,268 KB
testcase_16 AC 149 ms
41,940 KB
testcase_17 AC 153 ms
41,348 KB
testcase_18 AC 150 ms
41,800 KB
testcase_19 AC 158 ms
41,844 KB
testcase_20 AC 149 ms
41,800 KB
testcase_21 AC 151 ms
41,796 KB
testcase_22 AC 159 ms
41,540 KB
testcase_23 AC 155 ms
42,052 KB
testcase_24 AC 160 ms
41,484 KB
testcase_25 AC 158 ms
41,760 KB
testcase_26 AC 134 ms
41,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int max = -1001001001;
		int[] point = new int[101];
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
		}
		for(int i = 0 ; i < n ; i++) {
			b[i] = sc.nextInt();
		}
		for(int i = 0 ; i < n ; i++) {
			if(b[i] != 0) {
				point[b[i]] += a[i];
			}
		}
		for(int i = 1 ; i <= 100 ; i++) {
			max = Math.max(max, point[i]);
		}
		int ret = 0;
		for(int i = 0 ; i < n ; i++) {
			if(b[i] == 0) {
				ret += a[i];
			}
		}
		if(ret >= max) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
 	}
}
0