結果

問題 No.1687 What the Heck?
ユーザー NoneNone
提出日時 2021-10-06 02:25:08
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 211 bytes
コンパイル時間 346 ms
コンパイル使用メモリ 87,148 KB
実行使用メモリ 109,028 KB
最終ジャッジ日時 2023-09-30 08:37:37
合計ジャッジ時間 3,512 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,264 KB
testcase_01 AC 75 ms
71,352 KB
testcase_02 AC 75 ms
71,424 KB
testcase_03 AC 77 ms
71,552 KB
testcase_04 AC 76 ms
71,364 KB
testcase_05 AC 79 ms
71,128 KB
testcase_06 AC 78 ms
71,456 KB
testcase_07 AC 101 ms
86,164 KB
testcase_08 AC 106 ms
90,984 KB
testcase_09 AC 98 ms
85,956 KB
testcase_10 AC 93 ms
82,116 KB
testcase_11 AC 92 ms
82,504 KB
testcase_12 AC 130 ms
108,948 KB
testcase_13 AC 131 ms
108,916 KB
testcase_14 AC 131 ms
109,028 KB
testcase_15 AC 133 ms
108,936 KB
testcase_16 AC 128 ms
108,676 KB
testcase_17 AC 85 ms
76,476 KB
testcase_18 AC 129 ms
108,784 KB
testcase_19 AC 84 ms
76,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
P=list(map(lambda x:x-1,map(int, input().split())))
Q=[0]*N
for i,p in enumerate(P):
    Q[p]=i
res=0
S=N*(N+1)//2
for n in range(N)[::-1]:
    res=max(S - 2*(Q[n]+1),res)
    S-=Q[n]+1
print(res)
0