yes
Time Limit: 1 seconds
Memory Limit: 256 MB
Rating: 900
Problem StatementThe ultimate goal of the pigs is to steal the eggs of the Angry Birds. This time the bad piggies have succeeded, and the Angry Birds have discovered that some of their eggs have gone missing! There are originally $n$ eggs, but after the pigs have stolen some of them, there are only $m$ eggs left ($m$ will be strictly smaller than $n$). Before some eggs are stolen, the Angry Birds notice something interesting about their eggs: there is exactly one egg of each size. For example if $n$ = 5, the eggs will have size $1, 2, 3, 4, 5$. After the eggs are stolen, the Angry Birds record the sizes of the $m$ eggs left. Find the sum of the sizes of the eggs which are stolen.
InputYou are given two integers $n$ and $m$ on the first and second lines respectively $(1 \le m < n \le 500)$, then $m$ positive integers on the third line, ranging from $a_1, a_2, a_3, ...,a_m$. $(1 \le a_i \le m)$
OutputOn the first line, output the sum of the sizes of the eggs which are stolen.
Sample CasesSample Input 1: 5 3 1 2 4 Sample Output 1: 8 Sample Input 2: 10 7 1 3 4 5 7 8 9 Sample Output 2: 18Explanation
For the first sample case: Originally, there were 5 eggs with size $1, 2, 3, 4, 5.$ The eggs that are left have size $1, 2, 4$, so we can deduce that eggs of size $3$ and $5$ have been stolen. The sum $3 + 5 = 8$.
SourcesKL Coding Cup March 2023 > Angry Birds > Problem 2
Submit | Back