結果
問題 | No.216 FAC |
ユーザー |
|
提出日時 | 2017-04-21 12:37:34 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 136 ms / 1,000 ms |
コード長 | 1,123 bytes |
コンパイル時間 | 2,240 ms |
コンパイル使用メモリ | 85,620 KB |
実行使用メモリ | 41,720 KB |
最終ジャッジ日時 | 2024-07-20 05:02:14 |
合計ジャッジ時間 | 6,593 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
import java.util.HashMap;import java.util.Map;import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int N = Integer.parseInt(sc.next());int[][] scores = new int[N][2];for (int i = 0; i < N; i++) {scores[i][0] = Integer.parseInt(sc.next());}Map<Integer, Integer> map = new HashMap<>();for (int i = 0; i < N; i++) {int p = Integer.parseInt(sc.next());if (p == 0) {scores[i][1] = 0;continue;}if (!map.containsKey(p)) map.put(p, 0);map.put(p, map.get(p) + scores[i][0]);scores[i][1] = p;}int K = 0;for (int i = 0; i < N; i++) {if (scores[i][1] == 0) {K += scores[i][0];}}final int[] max = {-1};map.values().forEach(integer -> {if (max[0] < integer) max[0] = integer;});System.out.println((max[0] <= K)? "YES" : "NO");}}