幸运票AI (CI翻译)
Vasya thinks that lucky tickets are the tickets whose numbers are divisible by 3. He gathered quite a large collection of such tickets but one day his younger brother Leonid was having a sulk and decided to destroy the collection. First he tore every ticket exactly in two, but he didn’t think it was enough and Leonid also threw part of the pieces away. Having seen this, Vasya got terrified but still tried to restore the collection. He chose several piece pairs and glued each pair together so that each pair formed a lucky ticket. The rest of the pieces Vasya threw away reluctantly. Thus, after the gluing of the $2*t*$ pieces he ended up with $*t*$ tickets, each of which was lucky.
瓦西亚认为,编号能被 3 整除的票都是幸运票。他收集了相当多这样的票,但有一天,他的弟弟列昂尼德闹脾气,决定毁掉这些收藏。列昂尼德先把每张票恰好撕成两半,但他觉得这样还不够,于是又把其中一些碎片扔掉了。看到这一幕后,瓦西亚非常害怕,但仍然试图恢复这些票。他选出若干对碎片,并将每对碎片粘在一起,使每对碎片组成一张幸运票。其余的碎片则被瓦西亚不情愿地扔掉了。因此,在粘合 $2*t*$ 个碎片后,他得到了 $*t*$ 张票,并且每张票都是幸运票。AI (CI翻译)
When Leonid tore the tickets in two pieces, one piece contained the first several letters of his number and the second piece contained the rest.
列昂尼德把票撕成两半时,其中一半包含编号开头的若干位,另一半包含剩余部分。AI (CI翻译)
Vasya can glue every pair of pieces in any way he likes, but it is important that he gets a lucky ticket in the end. For example, pieces 123 and 99 can be glued in two ways: 12399 and 99123.
瓦西亚可以按照任意方式将每对碎片粘合起来,但最终得到的票必须是幸运票。例如,碎片 123 和 99 可以有两种粘合方式:12399 和 99123。AI (CI翻译)
What maximum number of tickets could Vasya get after that?
瓦西亚最多能得到多少张票?AI (CI翻译)
Input
输入格式
AI (CI翻译)The first line contains integer $*n*$ ($1 ≤ *n* ≤ 10^{4}$) — the number of pieces. The second line contains $*n*$ space-separated numbers $*a*_{*i*}$ ($1 ≤ *a*_{*i*} ≤ 10^{8}$) — the numbers on the pieces. Vasya can only glue the pieces in pairs. Even if the number of a piece is already lucky, Vasya should glue the piece with some other one for it to count as lucky. Vasya does not have to use all the pieces. The numbers on the pieces an on the resulting tickets may coincide.
第一行包含一个整数 $*n*$($1 ≤ *n* ≤ 10^{4}$),表示碎片的数量。第二行包含 $*n*$ 个以空格分隔的数字 $*a*_{*i}$($1 ≤ *a*_{*i*} ≤ 10^{8}$),表示碎片上的数字。瓦西亚只能将碎片两两粘合。即使某个碎片上的数字本身就是幸运数字,瓦西亚也必须将它与另一个碎片粘合后,才能将其计作一张幸运票。瓦西亚不必使用所有碎片。碎片上的数字以及最终票上的编号可以相同。AI (CI翻译)
Output
输出格式
AI (CI翻译)Print the single number — the maximum number of lucky tickets that will be able to be restored. Don't forget that every lucky ticket is made of exactly two pieces glued together.
输出一个数字,表示最多能够恢复的幸运票数量。注意,每张幸运票都必须由恰好两个粘合在一起的碎片组成。AI (CI翻译)
样例
3
123 123 99
1
6
1 1 1 23 10 3
1
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。