結果

問題 No.1687 What the Heck?
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-09-24 22:02:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 243 bytes
コンパイル時間 981 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 108,752 KB
最終ジャッジ日時 2023-09-18 21:22:04
合計ジャッジ時間 3,272 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,312 KB
testcase_01 AC 76 ms
71,296 KB
testcase_02 AC 78 ms
71,252 KB
testcase_03 AC 75 ms
71,364 KB
testcase_04 AC 75 ms
71,316 KB
testcase_05 AC 75 ms
71,320 KB
testcase_06 AC 75 ms
71,240 KB
testcase_07 AC 92 ms
85,736 KB
testcase_08 AC 98 ms
90,968 KB
testcase_09 AC 92 ms
85,728 KB
testcase_10 AC 88 ms
82,120 KB
testcase_11 AC 90 ms
82,164 KB
testcase_12 AC 122 ms
108,500 KB
testcase_13 AC 121 ms
108,700 KB
testcase_14 AC 122 ms
108,752 KB
testcase_15 AC 124 ms
108,480 KB
testcase_16 AC 122 ms
108,504 KB
testcase_17 AC 82 ms
76,380 KB
testcase_18 AC 123 ms
108,596 KB
testcase_19 AC 82 ms
76,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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