F - Replace by Average
Editorial
/


Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
項からなる正整数列 が与えられます。
あなたはこの数列に対して、次の操作を何度でも行うことができます。
- かつ となる整数 を選ぶ。 を に置き換える。
操作後の としてありうる最小値を求めてください。
制約
入力
入力は以下の形式で標準入力から与えられます。
出力
答えを出力してください。
入力例 1Copy
Copy
5 2 2 5 5 4
出力例 1Copy
Copy
13
次のように操作を行うことで、 を実現できます。
- として操作を行う。数列 は へと変化する。
- として操作を行う。数列 は へと変化する。
- として操作を行う。数列 は へと変化する。
入力例 2Copy
Copy
5 3 1 4 1 5
出力例 2Copy
Copy
11
入力例 3Copy
Copy
3 3 1 3
出力例 3Copy
Copy
7
入力例 4Copy
Copy
3 3 5 3
出力例 4Copy
Copy
9
Score : points
Problem Statement
Given is a sequence of positive integers .
You can do the following operation on this sequence any number of times.
- Choose integers such that and . Replace with .
Find the minimum possible value of after the operations.
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1Copy
Copy
5 2 2 5 5 4
Sample Output 1Copy
Copy
13
The following operations achieves .
- Do the operation with . The sequence is now .
- Do the operation with . The sequence is now .
- Do the operation with . The sequence is now .
Sample Input 2Copy
Copy
5 3 1 4 1 5
Sample Output 2Copy
Copy
11
Sample Input 3Copy
Copy
3 3 1 3
Sample Output 3Copy
Copy
7
Sample Input 4Copy
Copy
3 3 5 3
Sample Output 4Copy
Copy
9