結果
問題 | No.295 hel__world |
ユーザー | maspy |
提出日時 | 2020-05-04 13:43:49 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,934 bytes |
コンパイル時間 | 330 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 29,560 KB |
最終ジャッジ日時 | 2024-06-24 07:55:29 |
合計ジャッジ時間 | 5,749 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 31 ms
10,880 KB |
testcase_01 | AC | 30 ms
10,880 KB |
testcase_02 | AC | 31 ms
11,008 KB |
testcase_03 | AC | 31 ms
11,008 KB |
testcase_04 | AC | 31 ms
10,880 KB |
testcase_05 | WA | - |
testcase_06 | AC | 30 ms
10,880 KB |
testcase_07 | AC | 30 ms
10,880 KB |
testcase_08 | AC | 30 ms
10,880 KB |
testcase_09 | AC | 30 ms
10,880 KB |
testcase_10 | AC | 29 ms
11,008 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 30 ms
11,008 KB |
testcase_14 | AC | 30 ms
10,880 KB |
testcase_15 | AC | 29 ms
10,880 KB |
testcase_16 | AC | 30 ms
11,008 KB |
testcase_17 | AC | 29 ms
10,880 KB |
testcase_18 | AC | 30 ms
10,880 KB |
testcase_19 | AC | 31 ms
10,752 KB |
testcase_20 | AC | 30 ms
10,880 KB |
testcase_21 | AC | 31 ms
10,880 KB |
testcase_22 | AC | 31 ms
10,880 KB |
testcase_23 | AC | 31 ms
10,880 KB |
testcase_24 | WA | - |
testcase_25 | AC | 45 ms
10,880 KB |
testcase_26 | AC | 48 ms
10,880 KB |
testcase_27 | AC | 30 ms
10,880 KB |
testcase_28 | AC | 30 ms
10,752 KB |
testcase_29 | AC | 36 ms
10,880 KB |
testcase_30 | AC | 30 ms
10,880 KB |
testcase_31 | AC | 30 ms
11,008 KB |
testcase_32 | AC | 330 ms
29,048 KB |
testcase_33 | AC | 328 ms
29,560 KB |
testcase_34 | AC | 330 ms
29,560 KB |
testcase_35 | AC | 30 ms
10,880 KB |
testcase_36 | AC | 30 ms
10,880 KB |
testcase_37 | WA | - |
testcase_38 | AC | 30 ms
10,880 KB |
testcase_39 | AC | 30 ms
10,752 KB |
testcase_40 | AC | 30 ms
10,880 KB |
testcase_41 | AC | 31 ms
10,880 KB |
testcase_42 | AC | 30 ms
10,880 KB |
testcase_43 | AC | 31 ms
10,880 KB |
testcase_44 | AC | 31 ms
10,880 KB |
testcase_45 | AC | 30 ms
10,880 KB |
testcase_46 | AC | 30 ms
11,008 KB |
testcase_47 | AC | 30 ms
10,752 KB |
testcase_48 | AC | 32 ms
10,880 KB |
testcase_49 | AC | 31 ms
10,880 KB |
testcase_50 | AC | 37 ms
10,880 KB |
testcase_51 | AC | 30 ms
10,752 KB |
testcase_52 | AC | 30 ms
10,880 KB |
testcase_53 | AC | 371 ms
21,448 KB |
testcase_54 | AC | 358 ms
21,448 KB |
testcase_55 | AC | 362 ms
21,572 KB |
testcase_56 | AC | 366 ms
21,576 KB |
ソースコード
import sys from functools import lru_cache import itertools read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines INF = 2**62 S = tuple(map(int, readline().split())) T = tuple(x - ord('a') for x in read().rstrip()) L = [[] for _ in range(26)] last_ch = -1 last_len = 0 for x in T: if x != last_ch: L[x].append(1) else: L[x][-1] += 1 last_ch = x def check_zero(S, L): for a in range(26): # if S[a] > 0 and (not L[a]): # return True if S[a] < sum(L[a]): return True if check_zero(S, L): print(0) @lru_cache(None) def comb(n, k): if k < 0 or k > n: return 0 k = min(k, n - k) x = 1 for i in range(k): x *= (n - i) x //= (i + 1) if x >= INF: return INF return x def compute(n, nums): if not nums: return 1 n -= sum(nums) if not n: return 1 nums.sort(reverse=True) nums = nums[:70] if sum(nums) >= 6 and n > 10**4: return INF if n <= 10**4: A = nums[:] for _ in range(n): # 1 増やすと美味しいところを増やす i = max(range(len(nums)), key=lambda i: (A[i] + 1) / (A[i] - nums[i] + 1)) A[i] += 1 x = 1 for a, k in zip(A, nums): x *= comb(a, k) return x # n が大きくて、kは2種類 # 基本的には、同じくらいの大きさにすればよいので ret = 1 n += sum(nums) avg = n // len(nums) for p in itertools.product(range(avg - 4, avg + 5), repeat=len(nums)): if sum(p) != n: continue x = 1 for a, k in zip(p, nums): x *= comb(a, k) if ret < x: ret = x return ret x = 1 for n, nums in zip(S, L): x *= compute(n, nums) if x >= INF: x = 'hel' print(x)