結果

問題 No.216 FAC
ユーザー discoNeko
提出日時 2016-04-28 22:37:21
言語 Java
(openjdk 23)
結果
AC  
実行時間 56 ms / 1,000 ms
コード長 816 bytes
コンパイル時間 1,912 ms
コンパイル使用メモリ 77,428 KB
実行使用メモリ 50,416 KB
最終ジャッジ日時 2024-10-15 00:58:11
合計ジャッジ時間 4,123 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int n = Integer.parseInt(br.readLine());
		String[] str1 = br.readLine().split(" ");
		String[] str2 = br.readLine().split(" ");
		int[] p = new int [101];
		int max = 0;
		int sum = 0;
		for(int i = 0; i < n; i++){
			int a = Integer.parseInt(str1[i]);
			int b = Integer.parseInt(str2[i]);
			if(b!=0){
				p[b] += a;
				max = Math.max(max,p[b]);
			}else{
				sum += a;
			}
		}
		if(max>sum){
			sb.append("NO");
		}else{
			sb.append("YES");
		}
		System.out.println(sb);
	}
}
0