結果
問題 | No.1554 array_and_me |
ユーザー | tamato |
提出日時 | 2021-06-18 23:14:38 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,319 bytes |
コンパイル時間 | 150 ms |
コンパイル使用メモリ | 82,612 KB |
実行使用メモリ | 92,768 KB |
最終ジャッジ日時 | 2024-06-22 21:24:16 |
合計ジャッジ時間 | 10,279 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 49 ms
62,704 KB |
testcase_01 | AC | 245 ms
81,160 KB |
testcase_02 | AC | 229 ms
80,784 KB |
testcase_03 | AC | 241 ms
81,804 KB |
testcase_04 | AC | 228 ms
81,932 KB |
testcase_05 | AC | 244 ms
82,180 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 101 ms
92,440 KB |
testcase_12 | AC | 97 ms
92,468 KB |
testcase_13 | AC | 101 ms
92,300 KB |
testcase_14 | AC | 102 ms
92,440 KB |
testcase_15 | AC | 97 ms
92,308 KB |
testcase_16 | AC | 126 ms
79,612 KB |
testcase_17 | AC | 122 ms
79,196 KB |
testcase_18 | AC | 128 ms
79,212 KB |
testcase_19 | AC | 125 ms
79,340 KB |
testcase_20 | AC | 116 ms
78,908 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 239 ms
88,088 KB |
testcase_37 | AC | 235 ms
88,640 KB |
testcase_38 | AC | 236 ms
88,768 KB |
testcase_39 | AC | 247 ms
88,484 KB |
testcase_40 | AC | 248 ms
88,220 KB |
testcase_41 | WA | - |
ソースコード
mod = 998244353 eps = 10**-9 def main(): import sys from heapq import heappop, heappush input = sys.stdin.readline # comb init nmax = 10 ** 5 + 10 # change here fac = [0] * nmax finv = [0] * nmax inv = [0] * nmax fac[0] = 1 fac[1] = 1 finv[0] = 1 finv[1] = 1 inv[1] = 1 for i in range(2, nmax): fac[i] = fac[i - 1] * i % mod inv[i] = mod - inv[mod % i] * (mod // i) % mod finv[i] = finv[i - 1] * inv[i] % mod def comb(n, r): if n < r: return 0 else: return (fac[n] * ((finv[r] * finv[n - r]) % mod)) % mod for _ in range(int(input())): N, K = map(int, input().split()) A = list(map(int, input().split())) S = sum(A) B = [0] * N pq = [] for i in range(N): heappush(pq, (-A[i] * K, i)) for _ in range(K): v, i = heappop(pq) B[i] += 1 heappush(pq, (-A[i] * (1 / (B[i] + 1)), i)) S_inv = pow(S, mod-2, mod) T = K ans = 1 for i in range(N): ans = (ans * pow((A[i] * S_inv)%mod, B[i], mod))%mod ans = (ans * comb(T, B[i]))%mod T -= B[i] print(ans) assert T == 0 if __name__ == '__main__': main()