F - Maximum Composition
Editorial
/


Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
個の一次関数 が与えられます。 です。
以上 以下の相異なる 個の整数からなる長さ の数列 について、 としてありえる最大値を求めてください。
制約
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
出力
答えを整数として出力せよ。
入力例 1Copy
Copy
3 2 2 3 1 5 4 2
出力例 1Copy
Copy
26
ありえるすべての とそれに対応する の値は以下の通りです。
- :
- :
- :
- :
- :
- :
よって、 と出力します。
入力例 2Copy
Copy
10 3 48 40 34 22 24 37 45 40 48 31 49 44 45 40 44 6 35 22 39 28
出力例 2Copy
Copy
216223
Score : points
Problem Statement
You are given linear functions , where .
Find the maximum possible value of for a sequence of distinct integers between and , inclusive.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1Copy
Copy
3 2 2 3 1 5 4 2
Sample Output 1Copy
Copy
26
Here are all possible and the corresponding values of :
- :
- :
- :
- :
- :
- :
Therefore, print .
Sample Input 2Copy
Copy
10 3 48 40 34 22 24 37 45 40 48 31 49 44 45 40 44 6 35 22 39 28
Sample Output 2Copy
Copy
216223