結果
問題 | No.854 公平なりんご分配 |
ユーザー | qib |
提出日時 | 2022-12-29 20:23:12 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,363 bytes |
コンパイル時間 | 347 ms |
コンパイル使用メモリ | 82,228 KB |
実行使用メモリ | 321,232 KB |
最終ジャッジ日時 | 2024-11-24 20:23:48 |
合計ジャッジ時間 | 38,667 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
65,636 KB |
testcase_01 | AC | 50 ms
66,452 KB |
testcase_02 | AC | 45 ms
65,056 KB |
testcase_03 | AC | 51 ms
67,588 KB |
testcase_04 | AC | 48 ms
63,976 KB |
testcase_05 | AC | 50 ms
65,464 KB |
testcase_06 | AC | 48 ms
65,812 KB |
testcase_07 | AC | 49 ms
66,888 KB |
testcase_08 | AC | 50 ms
65,552 KB |
testcase_09 | AC | 48 ms
66,960 KB |
testcase_10 | AC | 49 ms
65,800 KB |
testcase_11 | AC | 49 ms
65,516 KB |
testcase_12 | AC | 50 ms
66,208 KB |
testcase_13 | AC | 49 ms
66,056 KB |
testcase_14 | AC | 48 ms
64,652 KB |
testcase_15 | AC | 48 ms
66,872 KB |
testcase_16 | AC | 49 ms
66,448 KB |
testcase_17 | AC | 51 ms
66,132 KB |
testcase_18 | AC | 49 ms
65,956 KB |
testcase_19 | AC | 52 ms
66,224 KB |
testcase_20 | AC | 51 ms
65,792 KB |
testcase_21 | AC | 51 ms
65,828 KB |
testcase_22 | AC | 112 ms
78,004 KB |
testcase_23 | AC | 77 ms
75,112 KB |
testcase_24 | AC | 118 ms
79,948 KB |
testcase_25 | AC | 82 ms
78,704 KB |
testcase_26 | AC | 119 ms
80,164 KB |
testcase_27 | AC | 82 ms
79,312 KB |
testcase_28 | AC | 107 ms
78,832 KB |
testcase_29 | AC | 65 ms
72,228 KB |
testcase_30 | AC | 90 ms
78,900 KB |
testcase_31 | AC | 110 ms
79,468 KB |
testcase_32 | AC | 250 ms
129,608 KB |
testcase_33 | AC | 350 ms
105,336 KB |
testcase_34 | AC | 520 ms
149,616 KB |
testcase_35 | AC | 435 ms
133,984 KB |
testcase_36 | AC | 419 ms
82,248 KB |
testcase_37 | AC | 256 ms
126,720 KB |
testcase_38 | AC | 220 ms
116,360 KB |
testcase_39 | AC | 826 ms
154,104 KB |
testcase_40 | AC | 404 ms
101,860 KB |
testcase_41 | AC | 424 ms
122,576 KB |
testcase_42 | AC | 471 ms
148,280 KB |
testcase_43 | AC | 747 ms
125,068 KB |
testcase_44 | AC | 630 ms
143,060 KB |
testcase_45 | AC | 711 ms
91,604 KB |
testcase_46 | AC | 815 ms
141,960 KB |
testcase_47 | AC | 420 ms
113,976 KB |
testcase_48 | AC | 380 ms
147,348 KB |
testcase_49 | AC | 357 ms
148,704 KB |
testcase_50 | AC | 230 ms
125,928 KB |
testcase_51 | AC | 952 ms
145,252 KB |
testcase_52 | AC | 617 ms
108,196 KB |
testcase_53 | AC | 259 ms
106,604 KB |
testcase_54 | AC | 446 ms
112,980 KB |
testcase_55 | AC | 215 ms
106,656 KB |
testcase_56 | AC | 200 ms
108,056 KB |
testcase_57 | AC | 359 ms
102,920 KB |
testcase_58 | AC | 675 ms
89,116 KB |
testcase_59 | AC | 205 ms
99,380 KB |
testcase_60 | AC | 354 ms
102,548 KB |
testcase_61 | AC | 261 ms
83,544 KB |
testcase_62 | AC | 456 ms
99,144 KB |
testcase_63 | AC | 283 ms
99,940 KB |
testcase_64 | AC | 216 ms
86,608 KB |
testcase_65 | AC | 308 ms
139,464 KB |
testcase_66 | AC | 379 ms
94,448 KB |
testcase_67 | AC | 369 ms
117,464 KB |
testcase_68 | AC | 419 ms
95,744 KB |
testcase_69 | AC | 228 ms
153,800 KB |
testcase_70 | AC | 196 ms
101,816 KB |
testcase_71 | AC | 200 ms
104,252 KB |
testcase_72 | AC | 666 ms
83,000 KB |
testcase_73 | AC | 227 ms
127,008 KB |
testcase_74 | AC | 414 ms
138,232 KB |
testcase_75 | AC | 304 ms
104,264 KB |
testcase_76 | AC | 320 ms
125,028 KB |
testcase_77 | AC | 363 ms
146,612 KB |
testcase_78 | AC | 599 ms
98,492 KB |
testcase_79 | AC | 444 ms
118,640 KB |
testcase_80 | AC | 499 ms
120,988 KB |
testcase_81 | AC | 299 ms
122,576 KB |
testcase_82 | MLE | - |
testcase_83 | MLE | - |
testcase_84 | MLE | - |
testcase_85 | MLE | - |
testcase_86 | MLE | - |
testcase_87 | MLE | - |
testcase_88 | MLE | - |
testcase_89 | MLE | - |
testcase_90 | MLE | - |
testcase_91 | MLE | - |
testcase_92 | MLE | - |
testcase_93 | MLE | - |
ソースコード
import math n = int(input()) a = list(map(int, input().split())) m = 2000 k = int(math.sqrt(10 ** 9)) dp = [None for _ in range(k + 1)] idx = {} for x in range(2, k + 1): if not dp[x] is None: continue dp[x] = x if x <= m: idx[x] = len(idx) for y in range(2 * x, k + 1, x): if not dp[y] is None: continue dp[y] = x s = [[0 for _ in range(n + 1)] for _ in range(len(idx))] for i in range(n): cur = a[i] while cur > 1: s[idx[dp[cur]]][i + 1] += 1 cur //= dp[cur] zero = [0 for _ in range(n + 1)] for i in range(n): zero[i + 1] = zero[i] if a[i] == 0: zero[i + 1] += 1 for i in range(len(idx)): for j in range(1, n + 1): s[i][j] += s[i][j - 1] q = int(input()) ans = [None for _ in range(q)] for i in range(q): p, l, r = map(int, input().split()) l -= 1 r -= 1 if p == 1 or zero[r + 1] - zero[l] > 0: ans[i] = "Yes" continue cnt = {} cur = p flg = True for x in range(2, k + 1): if cur == 1: break if dp[x] != x or cur % x != 0: continue if x > m: flg = False break y = idx[x] cnt[y] = 0 while cur % x == 0: cnt[y] += 1 cur //= x if not flg or cur > 1: ans[i] = "NO" continue if any(s[x][r + 1] - s[x][l] < v for x, v in cnt.items()): ans[i] = "NO" else: ans[i] = "Yes" print(*ans, sep="\n")