結果
問題 | No.118 門松列(2) |
ユーザー | roaris |
提出日時 | 2019-12-22 12:10:39 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 460 bytes |
コンパイル時間 | 308 ms |
コンパイル使用メモリ | 87,164 KB |
実行使用メモリ | 96,568 KB |
最終ジャッジ日時 | 2023-10-12 02:52:42 |
合計ジャッジ時間 | 4,398 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 93 ms
82,676 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 86 ms
82,236 KB |
testcase_07 | AC | 87 ms
82,484 KB |
testcase_08 | AC | 88 ms
82,396 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
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 | - |
ソースコード
def inv(x): return pow(x, MOD-2, MOD) def C(n, r): if r>n: return 0 return fact[n]*inv(fact[r])*inv(fact[n-r]) N = int(input()) A = list(map(int, input().split())) MOD = 10**9+7 A.append(-1) fact = [1] for i in range(1, 10**5+100): fact.append(fact[-1]*i%MOD) ans = C(N, 3) c = 1 for i in range(N): if A[i]!=A[i+1]: ans -= C(c, 3) ans -= C(c, 2)*(N-c) c = 1 else: c += 1 print(ans%MOD)