Preparing NOJ

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.

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.

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

6 1 9 9 7 9 3

2

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

1

3 4 5 7

0

Info

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