結果

問題 No.1687 What the Heck?
ユーザー hir355hir355
提出日時 2021-09-24 21:34:50
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 233 bytes
コンパイル時間 648 ms
コンパイル使用メモリ 87,288 KB
実行使用メモリ 108,676 KB
最終ジャッジ日時 2023-09-18 20:50:11
合計ジャッジ時間 3,386 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,144 KB
testcase_01 AC 72 ms
71,368 KB
testcase_02 AC 72 ms
71,136 KB
testcase_03 AC 72 ms
71,072 KB
testcase_04 AC 73 ms
71,316 KB
testcase_05 AC 71 ms
71,476 KB
testcase_06 AC 74 ms
71,388 KB
testcase_07 AC 92 ms
85,792 KB
testcase_08 AC 97 ms
90,816 KB
testcase_09 AC 91 ms
85,720 KB
testcase_10 AC 87 ms
82,244 KB
testcase_11 AC 86 ms
82,200 KB
testcase_12 AC 122 ms
108,580 KB
testcase_13 AC 122 ms
108,564 KB
testcase_14 AC 123 ms
108,672 KB
testcase_15 AC 123 ms
108,676 KB
testcase_16 AC 121 ms
108,428 KB
testcase_17 AC 81 ms
76,528 KB
testcase_18 AC 124 ms
108,616 KB
testcase_19 AC 79 ms
76,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
p = list(map(int, input().split()))
a = [0] * n
for i in range(n):
    a[p[i] - 1] = i
a.reverse()
ans = 0
t = n * (n + 1) // 2
for i in range(n):
    ans = max(ans, t - (a[i] + 1) * 2)
    t -= (a[i] + 1)
print(ans)
0