the topics are as follows
time limit: 20000ms
single point time limit: 1000ms
memory limit: 256MB
description
there are n monsters, and the health of the I monster is set to T by ai,.
now you have a skill that costs one gold coin to start each time. When the ability is started, the health of all living monsters will be-1. When the health of the monster is reduced to 0, it is considered to be destroyed.
In particular, if at least one monster dies after this ability, you will be rewarded with a gold coin.causes f (S) to pay a total of several gold coins to destroy the monsters in set S, that is, the number of gold coins spent minus the number of reward coins received.
to find the answer of S T f (S), take the model 109-7.
enter
the first line is a positive integer n.
the second row of n positive integers ai, represents the amount of blood of the I th monster.
1 n 105 ai
output
outputs a non-negative integer to represent the answer.
sample input
2
1 2
sample output
1
< hr >
the way of thinking I understand
the number of gold coins paid = the number of skills initiated-the number of gold coins rewarded. The number of launches for the
ability is: the weird health with the highest health.
the number of gold coins rewarded is: the number of different health points.
Let g (S) represent the maximum health of set S, h (S) represents the number of different health values in set S, then f (S) = g (S)-h (S).
my doubts
the calculation of the number of gold coins in a specific collection is very simple, but how to efficiently enumerate each collection (the maximum health value of each collection monster, and the composition of monsters less than the maximum health value), and calculate
the second and third points of this picture do not quite understand
attach the topic link link