#P7291. 「EZEC-5」人赢 加强版
「EZEC-5」人赢 加强版
Description
Xiao has an array with indices from to .
Xiao defines $f(x,y)=\begin{cases} \min(k_x,k_y) \times (x + y) &x \ne y \\ k_x\times x&x=y \end{cases}$.
Xiao wants to know, for any , what the maximum value of is. But she cannot solve it, so she asked the kind Xiao Z. However, Xiao Z, who really wants to show off in front of the girl, found that he also cannot solve it, so he has to ask the kind you for help.
Input Format
The first line contains an integer .
The second line contains integers , where the -th integer is . The meaning is as described above.
Output Format
Output one integer in a single line, representing the maximum value of over all .
3
3 2 1
6
5
3 4 5 4 3
28
Hint
Constraints
This problem uses bundled testdata.
- Subtask 1 (10 points): .
- Subtask 2 (20 points): .
- Subtask 3 (20 points): .
- Subtask 4 (10 points): it is guaranteed that all are equal.
- Subtask 5 (40 points): no special constraints.
For of the testdata, , .
A faster input method is recommended for this problem.
Fast input used by std:
#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
char buf[1<<21],*p1=buf,*p2=buf;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
Translated by ChatGPT 5
京公网安备 11011102002149号