結果

問題 No.696 square1001 and Permutation 5
ユーザー dangodango
提出日時 2023-06-13 19:32:30
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 438 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 278,552 KB
最終ジャッジ日時 2023-09-04 05:58:31
合計ジャッジ時間 39,053 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 72 ms
71,308 KB
testcase_02 AC 77 ms
71,340 KB
testcase_03 AC 85 ms
75,492 KB
testcase_04 AC 82 ms
75,648 KB
testcase_05 AC 92 ms
76,800 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 TLE -
testcase_11 AC 3,812 ms
260,532 KB
testcase_12 AC 77 ms
71,392 KB
testcase_13 AC 73 ms
71,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.set_int_max_str_digits(15000)
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