結果
問題 |
No.2615 ペアの作り方
|
ユーザー |
![]() |
提出日時 | 2024-01-26 23:12:46 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 446 bytes |
コンパイル時間 | 192 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 98,304 KB |
最終ジャッジ日時 | 2024-09-28 09:00:57 |
合計ジャッジ時間 | 2,712 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 RE * 3 |
ソースコード
MOD = 998244353 N = int(input()) X = list(map(int,input().split())) Y = list(map(int,input().split())) X.sort() Y.sort(reverse = True) i = 0 while X[i] < Y[i]: i += 1 a = i while X[i] == Y[i]: i += 1 b = i # fact(a) * fact(N-b)が答え cmax = max(a,N-b) cmin = min(a,N-b) tmp = 1 ans = 1 for i in range(1,cmax+1): tmp *= i tmp %= MOD if i == cmin: ans *= tmp if i == cmax: ans *= tmp ans %= MOD print(ans)