結果
問題 | No.854 公平なりんご分配 |
ユーザー | H3PO4 |
提出日時 | 2021-02-27 10:47:17 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,427 bytes |
コンパイル時間 | 302 ms |
コンパイル使用メモリ | 82,984 KB |
実行使用メモリ | 298,376 KB |
最終ジャッジ日時 | 2024-10-02 17:13:34 |
合計ジャッジ時間 | 50,359 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
54,704 KB |
testcase_01 | AC | 35 ms
53,532 KB |
testcase_02 | AC | 35 ms
53,868 KB |
testcase_03 | AC | 36 ms
53,680 KB |
testcase_04 | AC | 34 ms
54,420 KB |
testcase_05 | AC | 36 ms
53,604 KB |
testcase_06 | AC | 34 ms
53,132 KB |
testcase_07 | AC | 34 ms
54,364 KB |
testcase_08 | AC | 35 ms
53,520 KB |
testcase_09 | AC | 34 ms
53,772 KB |
testcase_10 | AC | 35 ms
53,188 KB |
testcase_11 | AC | 33 ms
54,444 KB |
testcase_12 | AC | 46 ms
61,440 KB |
testcase_13 | AC | 43 ms
60,964 KB |
testcase_14 | AC | 34 ms
53,788 KB |
testcase_15 | AC | 34 ms
53,632 KB |
testcase_16 | AC | 41 ms
60,760 KB |
testcase_17 | AC | 40 ms
61,076 KB |
testcase_18 | AC | 41 ms
60,600 KB |
testcase_19 | AC | 42 ms
62,176 KB |
testcase_20 | AC | 42 ms
60,324 KB |
testcase_21 | AC | 43 ms
60,760 KB |
testcase_22 | AC | 74 ms
74,204 KB |
testcase_23 | AC | 70 ms
73,024 KB |
testcase_24 | AC | 91 ms
78,708 KB |
testcase_25 | AC | 63 ms
70,648 KB |
testcase_26 | AC | 93 ms
78,804 KB |
testcase_27 | AC | 80 ms
75,932 KB |
testcase_28 | AC | 74 ms
75,472 KB |
testcase_29 | AC | 56 ms
67,504 KB |
testcase_30 | AC | 65 ms
70,500 KB |
testcase_31 | AC | 93 ms
78,548 KB |
testcase_32 | AC | 421 ms
155,376 KB |
testcase_33 | AC | 372 ms
94,004 KB |
testcase_34 | AC | 818 ms
185,136 KB |
testcase_35 | AC | 579 ms
162,640 KB |
testcase_36 | AC | 238 ms
81,612 KB |
testcase_37 | AC | 417 ms
150,748 KB |
testcase_38 | AC | 319 ms
99,088 KB |
testcase_39 | AC | 1,195 ms
193,360 KB |
testcase_40 | AC | 387 ms
92,464 KB |
testcase_41 | AC | 536 ms
146,392 KB |
testcase_42 | AC | 721 ms
183,056 KB |
testcase_43 | AC | 758 ms
150,268 KB |
testcase_44 | AC | 906 ms
176,412 KB |
testcase_45 | AC | 446 ms
88,336 KB |
testcase_46 | AC | 1,104 ms
175,692 KB |
testcase_47 | AC | 391 ms
97,384 KB |
testcase_48 | AC | 662 ms
183,040 KB |
testcase_49 | AC | 636 ms
184,560 KB |
testcase_50 | AC | 374 ms
149,596 KB |
testcase_51 | AC | 1,077 ms
180,240 KB |
testcase_52 | AC | 471 ms
97,144 KB |
testcase_53 | AC | 345 ms
95,376 KB |
testcase_54 | AC | 489 ms
99,880 KB |
testcase_55 | AC | 276 ms
94,312 KB |
testcase_56 | AC | 294 ms
94,964 KB |
testcase_57 | AC | 344 ms
92,632 KB |
testcase_58 | AC | 404 ms
86,868 KB |
testcase_59 | AC | 246 ms
90,616 KB |
testcase_60 | AC | 379 ms
93,548 KB |
testcase_61 | AC | 175 ms
81,796 KB |
testcase_62 | AC | 394 ms
92,052 KB |
testcase_63 | AC | 299 ms
92,324 KB |
testcase_64 | AC | 190 ms
83,084 KB |
testcase_65 | AC | 504 ms
170,804 KB |
testcase_66 | AC | 282 ms
88,496 KB |
testcase_67 | AC | 435 ms
101,404 KB |
testcase_68 | AC | 331 ms
90,320 KB |
testcase_69 | AC | 513 ms
191,996 KB |
testcase_70 | AC | 256 ms
91,992 KB |
testcase_71 | AC | 272 ms
93,288 KB |
testcase_72 | AC | 267 ms
82,080 KB |
testcase_73 | AC | 416 ms
152,868 KB |
testcase_74 | AC | 599 ms
170,460 KB |
testcase_75 | AC | 346 ms
93,740 KB |
testcase_76 | AC | 477 ms
150,664 KB |
testcase_77 | AC | 567 ms
181,492 KB |
testcase_78 | AC | 449 ms
91,600 KB |
testcase_79 | AC | 518 ms
102,340 KB |
testcase_80 | AC | 538 ms
144,372 KB |
testcase_81 | AC | 437 ms
146,612 KB |
testcase_82 | AC | 1,332 ms
291,428 KB |
testcase_83 | AC | 2,072 ms
291,296 KB |
testcase_84 | AC | 1,972 ms
291,408 KB |
testcase_85 | AC | 1,290 ms
255,716 KB |
testcase_86 | AC | 122 ms
92,104 KB |
testcase_87 | AC | 1,338 ms
291,572 KB |
testcase_88 | AC | 1,349 ms
291,412 KB |
testcase_89 | AC | 1,380 ms
291,300 KB |
testcase_90 | AC | 1,330 ms
291,416 KB |
testcase_91 | AC | 1,362 ms
291,292 KB |
testcase_92 | TLE | - |
testcase_93 | TLE | - |
ソースコード
import sys from array import array input = sys.stdin.buffer.readline def primes(n): is_prime = [True] * (n + 1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n ** 0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, n + 1, i): is_prime[j] = False return (i for i in range(n + 1) if is_prime[i]) N = int(input()) A = tuple(map(int, input().split())) Q = int(input()) queries = [tuple(map(int, input().split())) for _ in range(Q)] MAX = max(max(A), 1) P = tuple(primes(MAX)) L = len(P) acc_list = [array('I', [0] * (N + 1)) for _ in range(L)] INF = 10 ** 7 for i, a in enumerate(A, 1): if a: temp = a for x, pr in enumerate(P): ct = 0 while not temp % pr: temp //= pr ct += 1 acc_list[x][i] += ct else: for p in range(L): acc_list[p][i] = INF for p in range(L): for i in range(N): acc_list[p][i + 1] += acc_list[p][i] for p, l, r in queries: temp = p for x, pr in enumerate(P): ct = 0 while not temp % pr: temp //= pr ct += 1 diff = acc_list[x][r] - acc_list[x][l - 1] if diff >= INF: print('Yes') break elif diff < ct: print('NO') break else: print('Yes' if temp == 1 else 'NO')