Implementation
Nastya owns too many arrays now, so she wants to delete the least important of them. However, she discovered that this array is magic! Nastya now knows that the array has the following properties:
Nastya is always busy, so she wants to explode the array as fast as possible. Compute the minimum time in which the array can be exploded.
Read the question with I/O specifications at codeforces.com.
1. Think of grouping same elements together.
This problem becomes complicated if we think of eliminating elements individually because each element need not necessarily be unique.
For easier understanding, imagine the array is sorted. So all the same elements are now grouped together. Now each group can be eliminated by adding the respective integer. That is the final the answer will be the number of groups which is the number of distinct non-zero integers.
To find number of distinct integers we can use an STL container like Set (In a Set only distinct elements are added). Hence the size of the Set will be the number of distinct elements.
Written by Manoj