#abc263d. D - Left Right Operation
D - Left Right Operation
Score : points
问题描述
你得到一个长度为 的整数序列:。
你需要按顺序执行以下操作一次:
-
选择一个整数 。如果 等于 ,则不执行任何操作。如果 大于等于 ,则将 替换为 。
-
选择一个整数 。如果 等于 ,则不执行任何操作。如果 大于等于 ,则将 替换为 。
输出在执行完操作后, 中元素的最小可能和。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given an integer sequence of length : .
You will perform the following consecutive operations just once:
-
Choose an integer . If is , do nothing. If is or greater, replace each of with .
-
Choose an integer . If is , do nothing. If is or greater, replace each of with .
Print the minimum possible sum of the elements of after the operations.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
5 4 3
5 5 0 6 3
Sample Output 1
14
If you choose and , you will get , for the sum of , which is the minimum sum achievable.
Sample Input 2
4 10 10
1 2 3 4
Sample Output 2
10
If you choose and , you will get , for the sum of , which is the minimum sum achievable.
Sample Input 3
10 -5 -3
9 -6 10 -1 2 10 -1 7 -15 5
Sample Output 3
-58
, , and may be negative.
update @ 2024/3/10 11:07:43