#P16980. [NWERC 2017] High Score
[NWERC 2017] High Score
Background
From Northwestern Europe Regional Contest (NWERC) 2017 Problem H.
Original problem license: CC BY-SA.
Problem Description
Mårten and Simon enjoy playing the popular board game Seven Wonders, and have just finished a match. It is now time to tally the scores.
One of the ways to score in Seven Wonders is through the use of Science. During the game, the players may collect a number of Science tokens of three different types: Cog, Tablet, and Compass. If a player has Cogs, Tablets and Compasses, that player gets points.
However, the scoring is complicated by the concept of Wildcard Science tokens. For each Wildcard Science token a player has, she may count that as one of the three ordinary types of Science tokens. For instance, the first player in Sample Input 1 has Cogs, Tablet, Compasses, and Wildcard Science, so could thus choose to have the distributions , or of Cogs, Tablets and Compasses, respectively. The possible scores for this player are then , and depending on how the Wildcard Science is assigned. Thus, the maximum score for this player is .
Given the number of tokens each player in the game has, compute the maximum possible score that each of them can achieve if they assign their Wildcard Science tokens optimally.
Input Format
The input consists of one line with an integer (), the number of players in the game, followed by lines, each with four integers (), giving the number of Cog, Tablet, Compass, and Wildcard Science tokens of a player.
Output Format
For each player, in the same order they are given in the input, output the maximum score the player may get.
3
2 1 2 1
3 2 1 0
1 3 0 1
26
21
18