結果

問題 No.742 にゃんにゃんにゃん 猫の挨拶
ユーザー prd_xxxprd_xxx
提出日時 2018-10-05 22:13:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 158 ms / 2,500 ms
コード長 375 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 12,160 KB
最終ジャッジ日時 2024-04-20 17:59:40
合計ジャッジ時間 1,614 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,624 KB
testcase_01 AC 25 ms
10,624 KB
testcase_02 AC 26 ms
10,752 KB
testcase_03 AC 25 ms
10,752 KB
testcase_04 AC 26 ms
10,624 KB
testcase_05 AC 27 ms
10,752 KB
testcase_06 AC 26 ms
10,624 KB
testcase_07 AC 28 ms
10,752 KB
testcase_08 AC 32 ms
10,752 KB
testcase_09 AC 25 ms
10,752 KB
testcase_10 AC 29 ms
10,624 KB
testcase_11 AC 154 ms
12,160 KB
testcase_12 AC 158 ms
12,160 KB
testcase_13 AC 26 ms
10,624 KB
testcase_14 AC 26 ms
10,752 KB
testcase_15 AC 25 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
M = [int(input()) for i in range(N)]

bit = [0] * (N+1)
def bit_add(a,w):
    x = a
    while x <= N:
        bit[x] += w
        x += (x & -x)

def bit_sum(a):
    x = a
    ret = 0
    while x > 0:
        ret += bit[x]
        x -= (x & -x)
    return ret

ans = 0
for i in range(N-1,-1,-1):
    a = M[i]
    ans += bit_sum(a)
    bit_add(a,1)

print(ans)
0