問題一覧 > 通常問題

No.29 Power Up

レベル : / AI推定難易度 : 204 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 847
作問者 : yuki2006
お気に入りにしたユーザー ProblemId : 1 / 自分の提出
問題文最終更新日: 2024-06-18 11:51:37
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 29 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。