結果

問題 No.3469 ジャッジ結果の逆転数
コンテスト
ユーザー MM
提出日時 2026-03-06 22:53:07
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
RE  
実行時間 -
コード長 565 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 201 ms
コンパイル使用メモリ 85,448 KB
実行使用メモリ 115,836 KB
最終ジャッジ日時 2026-03-06 22:53:10
合計ジャッジ時間 1,919 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 RE * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

class BIT:
    def __init__(self, N):
        self.N = N
        self.bits = [0] * (self.N + 1)
        
    def update(self, i, x):
        while i <= self.N:
            self.bits[i] += x
            i += i & -i
    
    def total(self, i):
        res = 0
        
        while i > 0:
            res += self.bits[i]
            i -= i & -i
            
        return res

N = int(input())
A = list(map(int, input().split()))
bits = BIT(N)

count = 0

for i in range(N - 1, -1, -1):
    count += bits.total(A[i] - 1)
    bits.update(A[i], 1)
    
print(count)
0