結果

問題 No.1687 What the Heck?
ユーザー O2MTO2MT
提出日時 2021-09-29 14:29:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 345 bytes
コンパイル時間 1,598 ms
コンパイル使用メモリ 86,724 KB
実行使用メモリ 109,756 KB
最終ジャッジ日時 2023-09-23 11:07:41
合計ジャッジ時間 8,345 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,316 KB
testcase_01 AC 76 ms
71,216 KB
testcase_02 AC 76 ms
71,016 KB
testcase_03 WA -
testcase_04 AC 73 ms
71,060 KB
testcase_05 AC 74 ms
71,308 KB
testcase_06 AC 76 ms
71,228 KB
testcase_07 AC 248 ms
87,212 KB
testcase_08 AC 321 ms
92,888 KB
testcase_09 AC 245 ms
87,076 KB
testcase_10 AC 178 ms
84,044 KB
testcase_11 AC 189 ms
84,452 KB
testcase_12 AC 615 ms
109,536 KB
testcase_13 AC 611 ms
109,756 KB
testcase_14 AC 604 ms
109,724 KB
testcase_15 AC 605 ms
109,600 KB
testcase_16 AC 604 ms
109,588 KB
testcase_17 AC 106 ms
77,576 KB
testcase_18 AC 610 ms
109,548 KB
testcase_19 AC 82 ms
76,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
P = list(map(int,input().split()))
if len(P) == 1:
  print(0)
  exit()

A = [(P[i],i+1) for i in range(N)]
A.sort(reverse=True)
ac_A = [A[0][1]]
for i in range(1,N):
  ac_A.append(ac_A[-1]+A[i][1])

ans = N*(N+1)//2
num = 2*A[0][1]

for i in range(1,N):
  k,v = A[i]
  a = ac_A[i-1]
  num = min(num,a+2*v)

ans -= num
print(ans)
0