結果

問題 No.696 square1001 and Permutation 5
ユーザー beetbeet
提出日時 2018-06-09 00:57:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 525 bytes
コンパイル時間 657 ms
コンパイル使用メモリ 10,752 KB
実行使用メモリ 19,600 KB
最終ジャッジ日時 2023-09-13 01:26:22
合計ジャッジ時間 33,542 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 15 ms
7,900 KB
testcase_02 AC 15 ms
7,792 KB
testcase_03 AC 15 ms
7,900 KB
testcase_04 AC 17 ms
8,188 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 3,176 ms
19,432 KB
testcase_12 AC 15 ms
7,788 KB
testcase_13 AC 15 ms
7,728 KB
権限があれば一括ダウンロードができます

ソースコード

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
    c = 1
    for i in reversed(p):
        x = i
        y = i
        v = 0
        
        while x > 0:       
            v = v + bit[x]
            x = x - (x&-x)
            
        while y <= n:     
            bit[y] = bit[y] + 1
            y = y + (y&-y)
            
        t = a * v
        ans= t + ans
        a = a * c
        c = c + 1

    print(ans)
    
main()
0