結果

問題 No.1687 What the Heck?
ユーザー yudai1102jpyudai1102jp
提出日時 2021-09-24 21:44:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 529 ms / 2,000 ms
コード長 264 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 10,668 KB
実行使用メモリ 43,332 KB
最終ジャッジ日時 2023-09-18 21:03:04
合計ジャッジ時間 5,509 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,828 KB
testcase_01 AC 15 ms
7,748 KB
testcase_02 AC 16 ms
7,916 KB
testcase_03 AC 16 ms
7,832 KB
testcase_04 AC 15 ms
7,892 KB
testcase_05 AC 16 ms
7,760 KB
testcase_06 AC 15 ms
7,828 KB
testcase_07 AC 155 ms
20,764 KB
testcase_08 AC 243 ms
26,240 KB
testcase_09 AC 162 ms
20,436 KB
testcase_10 AC 101 ms
16,348 KB
testcase_11 AC 108 ms
16,568 KB
testcase_12 AC 519 ms
43,200 KB
testcase_13 AC 529 ms
43,200 KB
testcase_14 AC 528 ms
43,292 KB
testcase_15 AC 512 ms
43,332 KB
testcase_16 AC 504 ms
42,724 KB
testcase_17 AC 41 ms
10,728 KB
testcase_18 AC 512 ms
43,220 KB
testcase_19 AC 18 ms
8,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

P = list(map(int, input().split()))
P_index = [[P[i], i+1] for i in range(N)]

P_index.sort(key=lambda x: x[0], reverse=True)
ans = 0
Sum = (1+N)*N//2
for i in range(N):
    ans = max(ans, Sum-2*P_index[i][1])
    Sum -= P_index[i][1]
print(ans)
0