結果

問題 No.1687 What the Heck?
ユーザー rlangevinrlangevin
提出日時 2023-01-09 14:07:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 225 bytes
コンパイル時間 912 ms
コンパイル使用メモリ 86,752 KB
実行使用メモリ 110,312 KB
最終ジャッジ日時 2023-08-22 17:30:33
合計ジャッジ時間 3,816 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
70,952 KB
testcase_01 AC 74 ms
70,900 KB
testcase_02 AC 73 ms
70,944 KB
testcase_03 AC 72 ms
71,104 KB
testcase_04 AC 73 ms
70,944 KB
testcase_05 AC 73 ms
70,952 KB
testcase_06 AC 73 ms
71,108 KB
testcase_07 AC 106 ms
95,144 KB
testcase_08 AC 117 ms
104,276 KB
testcase_09 AC 103 ms
95,336 KB
testcase_10 AC 97 ms
88,580 KB
testcase_11 AC 96 ms
88,964 KB
testcase_12 AC 163 ms
110,308 KB
testcase_13 AC 164 ms
110,312 KB
testcase_14 AC 164 ms
110,096 KB
testcase_15 AC 163 ms
110,164 KB
testcase_16 AC 158 ms
109,332 KB
testcase_17 AC 83 ms
77,488 KB
testcase_18 AC 163 ms
110,220 KB
testcase_19 AC 81 ms
76,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
P = list(map(int, input().split()))
D = dict()
for i in range(N):
    D[P[i]] = i + 1
ans = 0
start = N * (N + 1)//2
for i in range(N, 0, -1):
    ans = max(ans, start - 2 * D[i])
    start -= D[i]
print(ans)
0