結果

問題 No.1525 Meximum Sum
ユーザー ChipppppChippppp
提出日時 2021-05-28 16:55:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 214 bytes
コンパイル時間 373 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 110,120 KB
最終ジャッジ日時 2023-08-08 15:02:00
合計ジャッジ時間 5,721 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,464 KB
testcase_01 AC 69 ms
71,272 KB
testcase_02 AC 68 ms
71,472 KB
testcase_03 AC 69 ms
71,352 KB
testcase_04 AC 69 ms
71,304 KB
testcase_05 AC 68 ms
71,224 KB
testcase_06 AC 70 ms
71,552 KB
testcase_07 AC 68 ms
71,260 KB
testcase_08 AC 104 ms
97,936 KB
testcase_09 AC 119 ms
107,084 KB
testcase_10 AC 84 ms
83,164 KB
testcase_11 AC 90 ms
88,976 KB
testcase_12 AC 116 ms
104,348 KB
testcase_13 AC 125 ms
109,812 KB
testcase_14 AC 125 ms
110,048 KB
testcase_15 AC 126 ms
109,808 KB
testcase_16 AC 127 ms
109,924 KB
testcase_17 AC 126 ms
109,936 KB
testcase_18 AC 127 ms
109,924 KB
testcase_19 AC 128 ms
109,808 KB
testcase_20 AC 128 ms
109,824 KB
testcase_21 AC 129 ms
109,916 KB
testcase_22 AC 127 ms
109,876 KB
testcase_23 AC 122 ms
110,120 KB
testcase_24 AC 120 ms
109,880 KB
testcase_25 AC 121 ms
109,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
p = [None] * N
for i in range(N):
  p[A[i]] = i
ans = 0
l, r = N, -1
for i in range(N):
  l, r = min(l, p[i]), max(r, p[i])
  ans += (l + 1) * (N - r)
print(ans)
0