Preparing NOJ

Beautiful Numbers

1000ms 524288K

Description:

Byteazar calls the positive integer beautiful if the sum of its digits is equal to 10. Byteazar got $$$n$$$ cards, each card containing one digit between 1 and 9, inclusively, on the face.

Count the maximal number of the beautiful numbers that can be built from the given cards simultaneously, i.e. that any card can be used in no more than one integer.

For example, if we have the cards with digits 1,9,9,7,9,3, we can build two beautiful numbers: first with the digits 1 and 9 and second with the digits 7 and 3. From cards 1,1,1,1,1,1,1,1,1,2,8 we can build only one beautiful number (use 8 and 2, or two ones and 8, or eight ones and 2). From the set of cards 4, 5, 7 we cannot build any beautiful number.

Input:

First line of the input contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — number of cards. Second line contains $$$n$$$ integers $$$a_i$$$ ($$$1 \le a_i \le 9$$$) — the numbers that are written on the faces of the cards.

Output:

Print one integer — the maximal number of the beautiful numbers that Byteazar can build simultaneously from the given cards.

Sample Input:

6
1 9 9 7 9 3

Sample Output:

2

Sample Input:

11
1 1 1 1 1 1 1 1 1 2 8

Sample Output:

1

Sample Input:

3
4 5 7

Sample Output:

0

Info

CodeForces Gym

Provider CodeForces Gym

Origin XXII Open Cup. Grand Prix of Korea (Division 2)

Code GYM103372C

Tags

Submitted 0

Passed 0

AC Rate 0%

Date 10/31/2021 14:45:36

Related

Nothing Yet