結果
| 問題 |
No.216 FAC
|
| コンテスト | |
| ユーザー |
YamaKasa
|
| 提出日時 | 2018-04-30 00:23:04 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 787 bytes |
| コンパイル時間 | 2,272 ms |
| コンパイル使用メモリ | 77,912 KB |
| 実行使用メモリ | 42,144 KB |
| 最終ジャッジ日時 | 2024-06-27 23:45:07 |
| 合計ジャッジ時間 | 7,253 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 WA * 5 |
ソースコード
import java.util.HashMap;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
int []a = new int[N];
int []b = new int[N];
for(int i = 0; i < N; i++) {
a[i] = scan.nextInt();
}
for(int i = 0; i < N; i++) {
b[i] = scan.nextInt();
}
scan.close();
HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
int k = 0;
for(int i = 0; i < N; i++) {
if(b[i] == 0) {
k += a[i];
}else {
if(map.get(b[i]) != null) {
map.put(b[i], map.get(b[i]) + a[i]);
}else {
map.put(b[i], a[i]);
}
}
}
for(int t : map.keySet()) {
if(k < t) {
System.out.println("NO");
System.exit(0);
}
}
System.out.println("YES");
}
}
YamaKasa