結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
40,272 KB
testcase_01 AC 137 ms
41,412 KB
testcase_02 AC 133 ms
41,556 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 132 ms
41,104 KB
testcase_07 AC 129 ms
41,836 KB
testcase_08 AC 118 ms
40,004 KB
testcase_09 AC 119 ms
40,208 KB
testcase_10 AC 137 ms
41,776 KB
testcase_11 AC 118 ms
40,060 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 133 ms
41,000 KB
testcase_15 RE -
testcase_16 AC 149 ms
41,228 KB
testcase_17 AC 150 ms
41,992 KB
testcase_18 AC 148 ms
41,200 KB
testcase_19 AC 146 ms
41,304 KB
testcase_20 AC 155 ms
41,536 KB
testcase_21 AC 151 ms
41,812 KB
testcase_22 AC 147 ms
41,488 KB
testcase_23 AC 152 ms
41,744 KB
testcase_24 AC 153 ms
41,508 KB
testcase_25 AC 157 ms
41,792 KB
testcase_26 RE -
権限があれば一括ダウンロードができます

ソースコード

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[n + 1];
		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 <= n ; 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