結果

問題 No.696 square1001 and Permutation 5
ユーザー beetbeet
提出日時 2018-06-09 00:50:38
言語 PyPy2
(7.3.15)
結果
RE  
実行時間 -
コード長 527 bytes
コンパイル時間 1,113 ms
コンパイル使用メモリ 77,424 KB
実行使用メモリ 87,832 KB
最終ジャッジ日時 2023-09-13 01:22:11
合計ジャッジ時間 3,058 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

    print(ans)
    
main()
0