結果

問題 No.1525 Meximum Sum
ユーザー LyricalMaestro
提出日時 2024-09-03 02:15:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 366 ms / 2,000 ms
コード長 457 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 82,484 KB
実行使用メモリ 114,304 KB
最終ジャッジ日時 2024-09-03 02:15:57
合計ジャッジ時間 8,040 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

# https://yukicoder.me/problems/no/1525




def main():
    N  = int(input())
    A = list(map(int, input().split()))

    a_list = [(i, a) for i, a in enumerate(A)]  
    a_list.sort(key=lambda x : x[1])


    left = N
    right = -1
    answer = 0
    for i, _ in a_list:
        left = min(left, i)
        right = max(right, i)

        ans = (left + 1) * (N - right)   
        answer += ans
    print(answer)





if __name__ == "__main__":
    main()
0