結果

問題 No.1687 What the Heck?
ユーザー raven7959raven7959
提出日時 2021-09-26 08:37:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 297 bytes
コンパイル時間 345 ms
コンパイル使用メモリ 86,724 KB
実行使用メモリ 108,584 KB
最終ジャッジ日時 2023-09-19 02:49:20
合計ジャッジ時間 3,522 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,228 KB
testcase_01 AC 72 ms
71,288 KB
testcase_02 AC 73 ms
71,240 KB
testcase_03 AC 73 ms
71,260 KB
testcase_04 AC 73 ms
71,036 KB
testcase_05 AC 75 ms
71,064 KB
testcase_06 AC 74 ms
71,236 KB
testcase_07 AC 99 ms
89,716 KB
testcase_08 AC 108 ms
97,088 KB
testcase_09 AC 98 ms
89,896 KB
testcase_10 AC 92 ms
84,420 KB
testcase_11 AC 95 ms
84,600 KB
testcase_12 AC 135 ms
108,444 KB
testcase_13 AC 133 ms
108,548 KB
testcase_14 AC 134 ms
108,584 KB
testcase_15 AC 132 ms
108,476 KB
testcase_16 AC 133 ms
108,480 KB
testcase_17 AC 88 ms
76,448 KB
testcase_18 AC 134 ms
108,564 KB
testcase_19 AC 81 ms
76,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
N=int(input())
P=list(map(int,input().split()))
if P==[1,2]:
  print(0)
  exit()
if P==[2,1]:
  print(1)
  exit()
idx=[-1]*N
for i in range(N):
  idx[P[i]-1]=i+1
idx_acc=list(accumulate(idx))
ans=0
for i in range(2,N):
  ans=max(ans,idx_acc[i-1]-idx[i])
print(ans)
0