結果

問題 No.696 square1001 and Permutation 5
ユーザー beetbeet
提出日時 2018-06-09 00:42:33
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 467 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 82,544 KB
実行使用メモリ 93,528 KB
最終ジャッジ日時 2024-06-30 12:07:15
合計ジャッジ時間 2,111 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other RE * 12
権限があれば一括ダウンロードができます

ソースコード

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)
            
        t = a * v
        ans= t + ans
        a = a * i

    print(ans)
    
main()
0