結果
問題 | No.1001 注文の多い順列 |
ユーザー |
![]() |
提出日時 | 2020-03-03 15:50:21 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,168 ms / 2,000 ms |
コード長 | 386 bytes |
コンパイル時間 | 267 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,520 KB |
最終ジャッジ日時 | 2024-10-13 22:44:22 |
合計ジャッジ時間 | 10,150 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
import sys m = 10**9+7 n = int(input()) l = [list(map(int, s.split())) for s in sys.stdin] l = sorted((x-t, t) for t, x in l) if sum(t for x, t in l) > len(l)//2: l = [(n-x, 1-t) for x, t in reversed(l)] c = [1]+[0]*n d = 1 for i, (x, t) in enumerate(l): d += t for j in range(d-1, -1, -1): c[j] = (c[j-1]*j - c[j]*(x-i+j) if t else c[j]*(x-i+j)) % m print(sum(c)%m)