結果

問題 No.216 FAC
コンテスト
ユーザー YOSHI
提出日時 2021-03-06 14:00:56
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 42 ms / 1,000 ms
+ 589µs
コード長 789 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,772 ms
コンパイル使用メモリ 90,324 KB
実行使用メモリ 41,216 KB
最終ジャッジ日時 2026-09-12 01:51:56
合計ジャッジ時間 6,021 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Stream;

public class No00000216_Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		int[] a = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int[] b = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int[] other = new int[100];

		int point = 0;
		for(int i = 0; i < n; i++) {
			if(b[i] == 0) {
				point += a[i];
			} else {
				other[b[i] - 1] += a[i];
			}
		}
		Arrays.sort(other);
		System.out.println(point >= other[99] ? "YES" : "NO");
	}
}
0