結果
問題 | No.1554 array_and_me |
ユーザー | tamato |
提出日時 | 2021-06-18 22:49:32 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,328 bytes |
コンパイル時間 | 225 ms |
コンパイル使用メモリ | 82,576 KB |
実行使用メモリ | 92,756 KB |
最終ジャッジ日時 | 2024-06-22 21:09:36 |
合計ジャッジ時間 | 12,205 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
62,160 KB |
testcase_01 | AC | 241 ms
81,428 KB |
testcase_02 | AC | 243 ms
81,036 KB |
testcase_03 | AC | 238 ms
81,404 KB |
testcase_04 | AC | 232 ms
81,432 KB |
testcase_05 | AC | 248 ms
82,044 KB |
testcase_06 | AC | 332 ms
92,400 KB |
testcase_07 | AC | 342 ms
92,404 KB |
testcase_08 | AC | 338 ms
92,156 KB |
testcase_09 | AC | 365 ms
92,304 KB |
testcase_10 | AC | 344 ms
92,132 KB |
testcase_11 | AC | 105 ms
92,756 KB |
testcase_12 | AC | 102 ms
92,384 KB |
testcase_13 | AC | 105 ms
92,188 KB |
testcase_14 | AC | 106 ms
92,364 KB |
testcase_15 | AC | 100 ms
92,496 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 319 ms
89,432 KB |
testcase_27 | AC | 333 ms
89,296 KB |
testcase_28 | AC | 328 ms
88,544 KB |
testcase_29 | AC | 319 ms
89,524 KB |
testcase_30 | AC | 337 ms
89,716 KB |
testcase_31 | AC | 333 ms
89,064 KB |
testcase_32 | AC | 327 ms
89,684 KB |
testcase_33 | AC | 336 ms
90,060 KB |
testcase_34 | AC | 330 ms
88,964 KB |
testcase_35 | AC | 340 ms
89,396 KB |
testcase_36 | AC | 257 ms
86,948 KB |
testcase_37 | AC | 260 ms
88,116 KB |
testcase_38 | AC | 260 ms
88,516 KB |
testcase_39 | AC | 252 ms
87,972 KB |
testcase_40 | AC | 253 ms
88,616 KB |
testcase_41 | AC | 244 ms
81,096 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] * K, i)) for _ in range(K): v, i = heappop(pq) B[i] += 1 heappush(pq, (-A[i] * ((K - B[i]) / (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()