結果

問題 No.1525 Meximum Sum
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2021-05-31 12:56:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 307 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 82,300 KB
実行使用メモリ 109,956 KB
最終ジャッジ日時 2024-04-26 08:04:21
合計ジャッジ時間 3,108 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,420 KB
testcase_01 AC 37 ms
53,164 KB
testcase_02 AC 36 ms
52,456 KB
testcase_03 AC 35 ms
52,616 KB
testcase_04 AC 34 ms
53,000 KB
testcase_05 AC 35 ms
52,548 KB
testcase_06 AC 34 ms
52,188 KB
testcase_07 AC 34 ms
53,132 KB
testcase_08 AC 73 ms
93,908 KB
testcase_09 AC 83 ms
103,216 KB
testcase_10 AC 56 ms
73,280 KB
testcase_11 AC 61 ms
82,116 KB
testcase_12 AC 80 ms
99,528 KB
testcase_13 AC 91 ms
108,376 KB
testcase_14 AC 92 ms
108,316 KB
testcase_15 AC 90 ms
109,400 KB
testcase_16 AC 87 ms
108,376 KB
testcase_17 AC 92 ms
108,360 KB
testcase_18 AC 90 ms
108,608 KB
testcase_19 AC 93 ms
109,340 KB
testcase_20 AC 89 ms
108,100 KB
testcase_21 AC 91 ms
109,956 KB
testcase_22 AC 89 ms
108,960 KB
testcase_23 AC 87 ms
108,540 KB
testcase_24 AC 87 ms
108,540 KB
testcase_25 AC 88 ms
108,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=[-1]+list(map(int,input().split()))
f=[0]*(n+3)
ind=[0]*(n+3)
for i in range(1,n+1):
    ind[a[i]]=i

l=ind[0]
r=ind[0]
f[1]=l*(n-r+1)

for x in range(2,n+1):
    r=max(r,ind[x-1])
    l=min(l,ind[x-1])
    f[x]=l*(n-r+1)


ans=0
for x in range(1,n+1):
    ans+=x*(f[x]-f[x+1])


print(ans)
0