結果
| 問題 | No.3469 ジャッジ結果の逆転数 |
| コンテスト | |
| ユーザー |
MM
|
| 提出日時 | 2026-03-06 22:53:07 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 565 bytes |
| 記録 | |
| コンパイル時間 | 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 |
ソースコード
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)
MM