結果
問題 | No.1554 array_and_me |
ユーザー | tamato |
提出日時 | 2021-06-18 23:15:42 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 499 ms / 2,000 ms |
コード長 | 1,315 bytes |
コンパイル時間 | 155 ms |
コンパイル使用メモリ | 82,688 KB |
実行使用メモリ | 92,544 KB |
最終ジャッジ日時 | 2024-06-22 21:24:52 |
合計ジャッジ時間 | 15,417 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
61,696 KB |
testcase_01 | AC | 276 ms
81,068 KB |
testcase_02 | AC | 268 ms
80,580 KB |
testcase_03 | AC | 272 ms
81,360 KB |
testcase_04 | AC | 271 ms
81,484 KB |
testcase_05 | AC | 291 ms
81,884 KB |
testcase_06 | AC | 472 ms
92,160 KB |
testcase_07 | AC | 499 ms
92,288 KB |
testcase_08 | AC | 466 ms
92,416 KB |
testcase_09 | AC | 483 ms
92,416 KB |
testcase_10 | AC | 473 ms
92,288 KB |
testcase_11 | AC | 122 ms
92,160 KB |
testcase_12 | AC | 123 ms
92,544 KB |
testcase_13 | AC | 127 ms
92,288 KB |
testcase_14 | AC | 121 ms
92,288 KB |
testcase_15 | AC | 118 ms
92,032 KB |
testcase_16 | AC | 152 ms
79,136 KB |
testcase_17 | AC | 151 ms
79,152 KB |
testcase_18 | AC | 162 ms
79,056 KB |
testcase_19 | AC | 150 ms
79,056 KB |
testcase_20 | AC | 148 ms
79,268 KB |
testcase_21 | AC | 461 ms
83,268 KB |
testcase_22 | AC | 458 ms
83,836 KB |
testcase_23 | AC | 461 ms
83,228 KB |
testcase_24 | AC | 455 ms
83,204 KB |
testcase_25 | AC | 439 ms
83,580 KB |
testcase_26 | AC | 450 ms
89,892 KB |
testcase_27 | AC | 447 ms
89,700 KB |
testcase_28 | AC | 460 ms
90,816 KB |
testcase_29 | AC | 456 ms
90,356 KB |
testcase_30 | AC | 457 ms
89,604 KB |
testcase_31 | AC | 465 ms
89,956 KB |
testcase_32 | AC | 458 ms
90,920 KB |
testcase_33 | AC | 472 ms
90,068 KB |
testcase_34 | AC | 455 ms
89,688 KB |
testcase_35 | AC | 474 ms
89,836 KB |
testcase_36 | AC | 282 ms
88,036 KB |
testcase_37 | AC | 295 ms
88,760 KB |
testcase_38 | AC | 285 ms
88,780 KB |
testcase_39 | AC | 282 ms
87,972 KB |
testcase_40 | AC | 287 ms
88,236 KB |
testcase_41 | AC | 273 ms
80,896 KB |
ソースコード
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], 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()