結果

問題 No.696 square1001 and Permutation 5
ユーザー beetbeet
提出日時 2018-06-09 00:38:11
言語 PyPy3
(7.3.13)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 488 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 87,148 KB
実行使用メモリ 268,016 KB
最終ジャッジ日時 2023-09-13 01:22:02
合計ジャッジ時間 36,461 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 74 ms
71,028 KB
testcase_02 AC 70 ms
71,440 KB
testcase_03 AC 76 ms
75,744 KB
testcase_04 AC 79 ms
75,856 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 3,703 ms
260,764 KB
testcase_12 AC 68 ms
71,504 KB
testcase_13 AC 68 ms
71,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    n = int(input())
    p = list(map(int, input().split()))

    bit = [0] * (n+1)
    
    ans = 1
    a = 1
    for i in range(1, n+1):
        x = p[n-i]
        
        v = 0
        while x > 0:
            v = v + bit[x]
            x = x - (x&-x)
            
        t = a * v
        ans= t + ans
        
        x = p[n-i]
        while x <= n:
            bit[x] = bit[x] + 1
            x = x + (x&-x)
            
        a = a * i

    print(ans)
    
main()
0