EIPAINTING - Art Exhibition 2
Xem dạng PDF
Gửi bài giải
Điểm:
1,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
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 \leq n \leq 10^6)~ which is the number of paintings in the exhibit.
- The next line contains ~n~ integers ~a_1, a_2, …, a_n~ ~(1 \leq a_i \leq 10^6)~, with ~a_i~ being the beauty of the ~i~-th picture.
Output
- Prints out a single integer - the maximum achievable happiness.
Example Input 1
5
20 30 10 50 40
Example Output 1
4
Example Input 2
4
200 100 100 200
Example Output 2
2
Bình luận