結果
問題 | No.854 公平なりんご分配 |
ユーザー | htensai |
提出日時 | 2020-01-28 09:06:52 |
言語 | Java21 (openjdk 21) |
結果 |
MLE
|
実行時間 | - |
コード長 | 2,628 bytes |
コンパイル時間 | 5,327 ms |
コンパイル使用メモリ | 81,944 KB |
実行使用メモリ | 587,932 KB |
最終ジャッジ日時 | 2023-10-13 08:34:51 |
合計ジャッジ時間 | 137,445 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 122 ms
55,380 KB |
testcase_01 | AC | 118 ms
55,992 KB |
testcase_02 | AC | 120 ms
55,992 KB |
testcase_03 | AC | 118 ms
55,908 KB |
testcase_04 | AC | 116 ms
55,612 KB |
testcase_05 | AC | 114 ms
55,728 KB |
testcase_06 | AC | 120 ms
55,524 KB |
testcase_07 | AC | 115 ms
55,596 KB |
testcase_08 | AC | 116 ms
57,628 KB |
testcase_09 | AC | 119 ms
55,756 KB |
testcase_10 | AC | 111 ms
55,984 KB |
testcase_11 | AC | 113 ms
55,436 KB |
testcase_12 | AC | 125 ms
55,960 KB |
testcase_13 | AC | 123 ms
56,244 KB |
testcase_14 | AC | 112 ms
55,592 KB |
testcase_15 | AC | 115 ms
55,572 KB |
testcase_16 | AC | 125 ms
57,736 KB |
testcase_17 | AC | 129 ms
56,308 KB |
testcase_18 | AC | 127 ms
55,720 KB |
testcase_19 | AC | 131 ms
55,856 KB |
testcase_20 | AC | 131 ms
56,196 KB |
testcase_21 | AC | 134 ms
55,552 KB |
testcase_22 | AC | 242 ms
60,872 KB |
testcase_23 | AC | 236 ms
61,068 KB |
testcase_24 | AC | 299 ms
64,772 KB |
testcase_25 | AC | 216 ms
58,936 KB |
testcase_26 | AC | 291 ms
64,720 KB |
testcase_27 | AC | 261 ms
64,908 KB |
testcase_28 | AC | 245 ms
60,680 KB |
testcase_29 | AC | 199 ms
58,072 KB |
testcase_30 | AC | 226 ms
59,248 KB |
testcase_31 | AC | 305 ms
65,192 KB |
testcase_32 | MLE | - |
testcase_33 | AC | 1,904 ms
270,724 KB |
testcase_34 | MLE | - |
testcase_35 | MLE | - |
testcase_36 | AC | 1,252 ms
88,332 KB |
testcase_37 | MLE | - |
testcase_38 | AC | 1,667 ms
295,744 KB |
testcase_39 | TLE | - |
testcase_40 | AC | 2,285 ms
250,044 KB |
testcase_41 | MLE | - |
testcase_42 | MLE | - |
testcase_43 | MLE | - |
testcase_44 | MLE | - |
testcase_45 | AC | 1,849 ms
155,684 KB |
testcase_46 | TLE | - |
testcase_47 | AC | 1,859 ms
312,596 KB |
testcase_48 | MLE | - |
testcase_49 | MLE | - |
testcase_50 | MLE | - |
testcase_51 | MLE | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | MLE | - |
testcase_66 | WA | - |
testcase_67 | MLE | - |
testcase_68 | WA | - |
testcase_69 | MLE | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | MLE | - |
testcase_74 | MLE | - |
testcase_75 | WA | - |
testcase_76 | MLE | - |
testcase_77 | TLE | - |
testcase_78 | WA | - |
testcase_79 | MLE | - |
testcase_80 | MLE | - |
testcase_81 | MLE | - |
testcase_82 | TLE | - |
testcase_83 | -- | - |
testcase_84 | -- | - |
testcase_85 | -- | - |
testcase_86 | -- | - |
testcase_87 | -- | - |
testcase_88 | -- | - |
testcase_89 | -- | - |
testcase_90 | -- | - |
testcase_91 | -- | - |
testcase_92 | -- | - |
testcase_93 | -- | - |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); HashMap<Integer, Integer>[] maps = new HashMap[n + 1]; maps[0] = new HashMap<>(); for (int i = 1; i <= n; i++) { maps[i] =(HashMap<Integer, Integer>)(maps[i - 1].clone()); int x = sc.nextInt(); for (int j = 2; j <= Math.sqrt(x); j++) { while (x % j == 0) { if (maps[i].containsKey(j)) { maps[i].put(j, maps[i].get(j) + 1); } else { maps[i].put(j, 1); } x /= j; } } if (x > 1) { if (maps[i].containsKey(x)) { maps[i].put(x, maps[i].get(x) + 1); } else { maps[i].put(x, 1); } } } int q = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { int p = sc.nextInt(); int left = sc.nextInt(); int right = sc.nextInt(); HashMap<Integer, Integer> target = (HashMap<Integer, Integer>)(maps[right].clone()); for (Map.Entry<Integer, Integer> entry : maps[left - 1].entrySet()) { target.put(entry.getKey(), target.get(entry.getKey()) - entry.getValue()); } boolean flag = true; for (int j = 2; j <= Math.sqrt(p) && flag; j++) { while (p % j == 0 && flag) { if (target.containsKey(j)) { int x = target.get(j); x--; if (x < 0) { flag = false; } else { target.put(j, x); } } else { flag = false; } p /= j; } } if (flag && p > 1) { if (target.containsKey(p)) { int x = target.get(p); x--; if (x < 0) { flag = false; } } else { flag = false; } } if (flag) { sb.append("Yes"); } else { sb.append("NO"); } sb.append("\n"); } System.out.print(sb); } }