結果

問題 No.1687 What the Heck?
ユーザー mymelochanmymelochan
提出日時 2021-09-24 23:00:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 206 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 86,804 KB
実行使用メモリ 110,764 KB
最終ジャッジ日時 2023-09-18 21:59:33
合計ジャッジ時間 3,529 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,368 KB
testcase_01 AC 71 ms
71,464 KB
testcase_02 AC 73 ms
71,496 KB
testcase_03 AC 72 ms
71,360 KB
testcase_04 AC 72 ms
71,320 KB
testcase_05 AC 72 ms
71,460 KB
testcase_06 AC 71 ms
71,516 KB
testcase_07 AC 104 ms
95,456 KB
testcase_08 AC 116 ms
104,816 KB
testcase_09 AC 104 ms
95,572 KB
testcase_10 AC 95 ms
89,096 KB
testcase_11 AC 95 ms
89,160 KB
testcase_12 AC 159 ms
110,488 KB
testcase_13 AC 159 ms
110,764 KB
testcase_14 AC 162 ms
110,688 KB
testcase_15 AC 159 ms
110,460 KB
testcase_16 AC 158 ms
109,548 KB
testcase_17 AC 82 ms
77,828 KB
testcase_18 AC 160 ms
110,464 KB
testcase_19 AC 80 ms
76,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

d = {}
for i in range(N):
    d[P[i]] = i+1

S = (N+1)*N//2
ma = 0
for i in range(N,0,-1):
    idx = d[i]
    ma = max(ma,S-idx*2)
    S -= idx
print(ma)
0