結果

問題 No.696 square1001 and Permutation 5
ユーザー dangodango
提出日時 2023-06-13 19:26:32
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 393 bytes
コンパイル時間 1,386 ms
コンパイル使用メモリ 86,380 KB
実行使用メモリ 287,232 KB
最終ジャッジ日時 2023-09-04 05:50:54
合計ジャッジ時間 24,689 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 77 ms
71,348 KB
testcase_02 AC 76 ms
71,580 KB
testcase_03 AC 82 ms
76,044 KB
testcase_04 AC 85 ms
75,616 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 TLE -
testcase_11 AC 4,009 ms
260,632 KB
testcase_12 AC 75 ms
71,652 KB
testcase_13 AC 75 ms
71,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
P = list(map(int,input().split()))
BIT = [0 for i in range(N + 1)]
def SUM(X):
    R = 0
    while X > 0:
        R += BIT[X]
        X -= (X & -X)
    return R
def ADD(X, Y):
    if(X == 0):
        return
    while X <= N:
        BIT[X] += Y
        X = X + (X & -X)
R = 1
X = 1
for i in range(1, N + 1):
    R += SUM(P[N - i]) * X
    ADD(P[N - i], 1)
    X *= i
print(R)
0