Submit | All submissions | Best solutions | Back to list |
EIPAINTING - Art Exhibition 2 |
The EIU Algorithm and Design Analysis student group received an invitation to an art exhibition, of course, everyone was delighted to receive this invitation. People are even happier if they see a good picture and then a better one. For each pair of such pictures, everyone's happiness increases by 1.
The owner of the exhibition really wanted to make the group of students happy. Help the exhibitor arrange the paintings so that everyone's happiness is maximized.
Input
- The first line is an integer n (1 <= n <= 1000000) which is the number of paintings in the exhibit.
- The next line contains n integers a1, a2,….an (1 <= ai <= 1000000), with ai being the beauty of the ith picture.
Output
Prints out a single integer - the maximum achievable happiness.
Example
Input: 5
20 30 10 50 40 Output: 4Input: 4
200 100 100 200 Output: 2
Added by: | Ha Minh Ngoc |
Date: | 2016-10-08 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |