結果

問題 No.1687 What the Heck?
ユーザー lloyzlloyz
提出日時 2021-11-22 22:34:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 263 ms / 2,000 ms
コード長 273 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 10,524 KB
実行使用メモリ 30,752 KB
最終ジャッジ日時 2023-09-06 17:33:37
合計ジャッジ時間 3,633 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,908 KB
testcase_01 AC 14 ms
7,792 KB
testcase_02 AC 14 ms
7,796 KB
testcase_03 AC 15 ms
7,752 KB
testcase_04 AC 14 ms
7,964 KB
testcase_05 AC 14 ms
7,828 KB
testcase_06 AC 14 ms
7,832 KB
testcase_07 AC 93 ms
16,328 KB
testcase_08 AC 132 ms
19,764 KB
testcase_09 AC 92 ms
15,672 KB
testcase_10 AC 67 ms
13,848 KB
testcase_11 AC 71 ms
13,896 KB
testcase_12 AC 263 ms
29,880 KB
testcase_13 AC 253 ms
29,816 KB
testcase_14 AC 247 ms
29,824 KB
testcase_15 AC 260 ms
29,948 KB
testcase_16 AC 247 ms
30,752 KB
testcase_17 AC 32 ms
10,272 KB
testcase_18 AC 262 ms
29,972 KB
testcase_19 AC 18 ms
8,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
P = list(map(int, input().split()))

Pos = [0 for _ in range(n + 1)]
for i in range(n):
    Pos[P[i]] = i + 1

ans = 0
s = n * (n + 1) // 2
for i in range(n, 0, -1):
    tmp = s - 2 * Pos[i]
    ans = max(ans, tmp)
    s -= Pos[i]
print(ans)
0