結果

問題 No.1525 Meximum Sum
ユーザー ChipppppChippppp
提出日時 2021-05-28 23:17:34
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 251 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 110,148 KB
最終ジャッジ日時 2023-08-08 15:03:49
合計ジャッジ時間 4,529 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,352 KB
testcase_01 AC 71 ms
71,376 KB
testcase_02 AC 69 ms
71,352 KB
testcase_03 AC 70 ms
71,036 KB
testcase_04 AC 71 ms
71,372 KB
testcase_05 AC 71 ms
71,280 KB
testcase_06 AC 70 ms
71,412 KB
testcase_07 AC 71 ms
71,560 KB
testcase_08 AC 107 ms
97,816 KB
testcase_09 AC 121 ms
107,348 KB
testcase_10 AC 85 ms
83,340 KB
testcase_11 AC 92 ms
88,944 KB
testcase_12 AC 116 ms
104,220 KB
testcase_13 AC 129 ms
109,828 KB
testcase_14 AC 130 ms
109,764 KB
testcase_15 AC 129 ms
109,832 KB
testcase_16 AC 130 ms
109,896 KB
testcase_17 AC 131 ms
109,992 KB
testcase_18 AC 128 ms
109,988 KB
testcase_19 AC 129 ms
110,108 KB
testcase_20 AC 129 ms
110,148 KB
testcase_21 AC 129 ms
109,880 KB
testcase_22 AC 127 ms
110,060 KB
testcase_23 AC 122 ms
110,028 KB
testcase_24 AC 122 ms
110,088 KB
testcase_25 AC 123 ms
110,032 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
left, right = N, -1
for i in range(N):
    left, right = min(left, p[i]), max(right, p[i])
    ans += (left + 1) * (N - right)

print(ans)
0