結果

問題 No.216 FAC
ユーザー GrenacheGrenache
提出日時 2015-05-26 22:39:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 152 ms / 1,000 ms
コード長 607 bytes
コンパイル時間 2,210 ms
コンパイル使用メモリ 74,220 KB
実行使用メモリ 42,136 KB
最終ジャッジ日時 2024-04-23 01:19:30
合計ジャッジ時間 6,732 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
41,232 KB
testcase_01 AC 130 ms
41,632 KB
testcase_02 AC 124 ms
41,244 KB
testcase_03 AC 134 ms
41,556 KB
testcase_04 AC 130 ms
41,460 KB
testcase_05 AC 116 ms
41,588 KB
testcase_06 AC 123 ms
41,352 KB
testcase_07 AC 124 ms
41,460 KB
testcase_08 AC 131 ms
41,484 KB
testcase_09 AC 127 ms
41,840 KB
testcase_10 AC 112 ms
41,848 KB
testcase_11 AC 113 ms
41,468 KB
testcase_12 AC 123 ms
41,472 KB
testcase_13 AC 126 ms
41,620 KB
testcase_14 AC 125 ms
41,428 KB
testcase_15 AC 129 ms
41,392 KB
testcase_16 AC 134 ms
42,136 KB
testcase_17 AC 147 ms
42,008 KB
testcase_18 AC 141 ms
41,768 KB
testcase_19 AC 140 ms
41,672 KB
testcase_20 AC 152 ms
41,976 KB
testcase_21 AC 145 ms
41,944 KB
testcase_22 AC 144 ms
41,352 KB
testcase_23 AC 136 ms
41,556 KB
testcase_24 AC 135 ms
41,728 KB
testcase_25 AC 139 ms
41,572 KB
testcase_26 AC 128 ms
41,488 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];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		int[] score = new int[200];
		int sco = 0;
		for (int i = 0; i < n; i++) {
			int b = sc.nextInt();
			if (b != 0) {
				score[b - 1] += a[i];
			} else {
				sco += a[i];
			}
		}

		for (int i = 0; i < 200; i++) {
			if (score[i] > sco) {
				System.out.println("NO");
				sc.close();
				return;
			}
		}
		
		System.out.println("YES");
		
		sc.close();
	}
}
0