結果
問題 | No.854 公平なりんご分配 |
ユーザー | H3PO4 |
提出日時 | 2021-02-27 10:55:46 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,421 bytes |
コンパイル時間 | 203 ms |
コンパイル使用メモリ | 82,280 KB |
実行使用メモリ | 296,864 KB |
最終ジャッジ日時 | 2024-10-02 17:14:36 |
合計ジャッジ時間 | 47,825 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
60,728 KB |
testcase_01 | AC | 39 ms
52,984 KB |
testcase_02 | AC | 34 ms
53,140 KB |
testcase_03 | AC | 36 ms
53,168 KB |
testcase_04 | AC | 35 ms
53,660 KB |
testcase_05 | AC | 35 ms
54,632 KB |
testcase_06 | AC | 35 ms
54,552 KB |
testcase_07 | AC | 35 ms
53,264 KB |
testcase_08 | AC | 37 ms
54,120 KB |
testcase_09 | AC | 36 ms
53,520 KB |
testcase_10 | AC | 36 ms
54,452 KB |
testcase_11 | AC | 36 ms
54,016 KB |
testcase_12 | AC | 40 ms
60,980 KB |
testcase_13 | AC | 44 ms
60,636 KB |
testcase_14 | AC | 33 ms
54,052 KB |
testcase_15 | AC | 35 ms
54,684 KB |
testcase_16 | AC | 41 ms
60,860 KB |
testcase_17 | AC | 41 ms
61,904 KB |
testcase_18 | AC | 41 ms
61,700 KB |
testcase_19 | AC | 41 ms
60,632 KB |
testcase_20 | AC | 42 ms
60,844 KB |
testcase_21 | AC | 40 ms
61,200 KB |
testcase_22 | AC | 72 ms
75,420 KB |
testcase_23 | AC | 67 ms
72,912 KB |
testcase_24 | AC | 87 ms
79,004 KB |
testcase_25 | AC | 63 ms
69,916 KB |
testcase_26 | AC | 91 ms
78,452 KB |
testcase_27 | AC | 75 ms
75,248 KB |
testcase_28 | AC | 76 ms
74,868 KB |
testcase_29 | AC | 55 ms
67,796 KB |
testcase_30 | AC | 63 ms
69,840 KB |
testcase_31 | AC | 88 ms
78,536 KB |
testcase_32 | AC | 404 ms
156,132 KB |
testcase_33 | AC | 354 ms
96,184 KB |
testcase_34 | AC | 751 ms
188,988 KB |
testcase_35 | AC | 558 ms
164,496 KB |
testcase_36 | AC | 214 ms
83,924 KB |
testcase_37 | AC | 393 ms
151,428 KB |
testcase_38 | AC | 302 ms
99,012 KB |
testcase_39 | AC | 1,159 ms
198,432 KB |
testcase_40 | AC | 372 ms
94,304 KB |
testcase_41 | AC | 525 ms
148,012 KB |
testcase_42 | AC | 688 ms
186,168 KB |
testcase_43 | AC | 752 ms
154,392 KB |
testcase_44 | AC | 862 ms
180,740 KB |
testcase_45 | AC | 461 ms
93,800 KB |
testcase_46 | AC | 1,103 ms
181,028 KB |
testcase_47 | AC | 378 ms
98,932 KB |
testcase_48 | AC | 641 ms
184,420 KB |
testcase_49 | AC | 611 ms
185,800 KB |
testcase_50 | AC | 362 ms
150,116 KB |
testcase_51 | AC | 1,014 ms
173,940 KB |
testcase_52 | AC | 445 ms
101,996 KB |
testcase_53 | AC | 309 ms
97,684 KB |
testcase_54 | AC | 470 ms
104,576 KB |
testcase_55 | AC | 264 ms
95,796 KB |
testcase_56 | AC | 277 ms
95,240 KB |
testcase_57 | AC | 322 ms
94,908 KB |
testcase_58 | AC | 408 ms
92,056 KB |
testcase_59 | AC | 239 ms
91,060 KB |
testcase_60 | AC | 367 ms
96,508 KB |
testcase_61 | AC | 176 ms
83,884 KB |
testcase_62 | AC | 383 ms
95,792 KB |
testcase_63 | AC | 289 ms
96,008 KB |
testcase_64 | AC | 186 ms
84,276 KB |
testcase_65 | AC | 462 ms
172,132 KB |
testcase_66 | AC | 257 ms
90,232 KB |
testcase_67 | AC | 401 ms
105,152 KB |
testcase_68 | AC | 321 ms
95,428 KB |
testcase_69 | AC | 482 ms
192,292 KB |
testcase_70 | AC | 244 ms
92,876 KB |
testcase_71 | AC | 254 ms
94,620 KB |
testcase_72 | AC | 256 ms
86,020 KB |
testcase_73 | AC | 372 ms
154,048 KB |
testcase_74 | AC | 565 ms
174,836 KB |
testcase_75 | AC | 321 ms
96,160 KB |
testcase_76 | AC | 425 ms
154,600 KB |
testcase_77 | AC | 513 ms
185,836 KB |
testcase_78 | AC | 430 ms
97,672 KB |
testcase_79 | AC | 477 ms
107,268 KB |
testcase_80 | AC | 498 ms
148,740 KB |
testcase_81 | AC | 411 ms
149,904 KB |
testcase_82 | AC | 1,211 ms
296,232 KB |
testcase_83 | AC | 1,870 ms
296,608 KB |
testcase_84 | AC | 1,857 ms
296,488 KB |
testcase_85 | AC | 1,211 ms
259,312 KB |
testcase_86 | AC | 129 ms
105,796 KB |
testcase_87 | AC | 1,202 ms
296,548 KB |
testcase_88 | AC | 1,262 ms
296,704 KB |
testcase_89 | AC | 1,246 ms
296,856 KB |
testcase_90 | AC | 1,206 ms
296,728 KB |
testcase_91 | AC | 1,224 ms
296,736 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 = [(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')