No.29 Power Up
タグ : / 解いたユーザー数 847
作問者 :
Problem Statement
Quin is playing an RPG.
In this RPG, there are 10 types of items (each numbered), and there is a mechanism where you can power up by collecting 2 of the "same item" or 4 of "any items".
The items used are consumed and disappear.
Then, when you defeat an enemy, you can receive some 3 items.
(You may receive identical items.)
Here, assume there is no upper limit on the items you can hold, and the combinations of items can be chosen freely. (Assume that powering up does not happen automatically.)
Considering that you defeat enemies N times, find the maximum number of power-ups at that time.
Input
N a1 b1 c1 a2 b2 c2 ・・・・ aN bN cN
The first line gives N (1<=N<=100), the number of times you defeat an enemy.
From the second line onward, the numbers ai,bi,ci(1<=ai,bi,ci<=10) of the 3 items received when defeating an enemy for the i-th(1<=i<=N) time are given, separated by single-byte spaces.
Output
Output the maximum number of power-ups as a string. Include a newline at the end of the output.
Sample
Sample 1
Input
5 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5
Output
6
Since you have collected 2 each of items 1,2,3,4,5, you can power up 5 times.
Furthermore, using items 6,7,8,9, you can power up once more, for a total of 6 power-ups.
Sample 2
Input
3 1 1 1 1 1 1 1 1 1
Output
4
Sample 3
Input
3 1 2 3 5 4 1 1 9 2
Output
3
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。