結果

問題 No.696 square1001 and Permutation 5
ユーザー beetbeet
提出日時 2018-06-09 00:25:10
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 679 bytes
コンパイル時間 426 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 849,528 KB
最終ジャッジ日時 2023-09-13 01:01:32
合計ジャッジ時間 7,295 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

    bit = list(map(int, [0 for i in range(n+1)]))
    def get(x):
        res = 0
        while x > 0:
            res = res + bit[x]
            x = x - (x&-x)
        return res
        
    def add(x, y):
        if(x == 0):
            return
        while x <= n:
            bit[x] = bit[x] + y
            x = x + (x&-x)
            
            
    
    buf = list(map(int, [0 for i in range(8192)]))
    a = 1
    for i in range(1, n+1):
        t = a * get(p[n-i])
        buf[i&8191] = t + buf[i&8191]
        add(p[n-i], 1)
        a = a * i

    ans = 1 + sum(buf)
    print(ans)
    
main()
0