結果

問題 No.1001 注文の多い順列
ユーザー chinchillachinchilla
提出日時 2020-03-03 15:16:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 292 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 10,864 KB
実行使用メモリ 9,068 KB
最終ジャッジ日時 2023-08-04 01:31:18
合計ジャッジ時間 17,571 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,880 KB
testcase_01 AC 15 ms
7,800 KB
testcase_02 AC 15 ms
7,856 KB
testcase_03 AC 14 ms
7,864 KB
testcase_04 AC 14 ms
7,880 KB
testcase_05 AC 15 ms
7,920 KB
testcase_06 AC 14 ms
7,860 KB
testcase_07 AC 14 ms
7,800 KB
testcase_08 AC 14 ms
7,800 KB
testcase_09 AC 14 ms
7,800 KB
testcase_10 AC 14 ms
7,808 KB
testcase_11 AC 15 ms
7,812 KB
testcase_12 AC 14 ms
7,772 KB
testcase_13 AC 17 ms
7,772 KB
testcase_14 AC 20 ms
7,776 KB
testcase_15 AC 23 ms
7,860 KB
testcase_16 AC 18 ms
7,856 KB
testcase_17 AC 18 ms
7,856 KB
testcase_18 AC 854 ms
8,832 KB
testcase_19 AC 833 ms
8,836 KB
testcase_20 AC 483 ms
8,520 KB
testcase_21 AC 451 ms
8,572 KB
testcase_22 AC 1,115 ms
8,944 KB
testcase_23 AC 1,038 ms
9,016 KB
testcase_24 AC 765 ms
9,024 KB
testcase_25 AC 989 ms
8,920 KB
testcase_26 AC 1,893 ms
8,924 KB
testcase_27 AC 1,856 ms
8,904 KB
testcase_28 AC 1,794 ms
8,840 KB
testcase_29 AC 201 ms
9,056 KB
testcase_30 AC 244 ms
8,976 KB
testcase_31 AC 324 ms
9,004 KB
testcase_32 AC 22 ms
9,032 KB
testcase_33 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
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)
0