#P2422. 良好的感觉

    ID: 3665 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>动态规划 DP单调队列

良好的感觉

Background

{{}}

Problem Description

kkk built a human sensation analyzer. Each day, a person has a feeling value AiA_i; the larger AiA_i, the more comfortable the person feels. Over a time segment [i,j]\left[i, j\right], a person's comfort level is defined as the feeling value on the least comfortable day in [i,j]\left[i, j\right] ×\times the sum of the feeling values of all days in [i,j]\left[i, j\right]. Now, given kkk's feeling values over NN consecutive days, which time segment makes kkk feel the most comfortable?

Input Format

The first line contains NN, the number of days for which data was recorded. The second line contains NN integers, the feeling value of each day.

Output Format

Output one line: the comfort value of the most comfortable time segment.

6
3 1 6 4 5 2
60

Hint

kkk's most comfortable time segment is from day 33 to day 55, comfort value: (6+4+5)×4=60(6+4+5)\times4=60.

Constraints:

  • For 30%30\% of the testdata, 1N1001 \le N \le 100.
  • For 70%70\% of the testdata, 1N20001 \le N \le 2000.
  • For 100%100\% of the testdata, 1N1051 \le N \le 10^5, 11 \le feeling value 106\le 10^6.}}

Translated by ChatGPT 5