포럼
문제 ICPC00186

H. High Score

설명

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 \(a\) Cogs, \(b\) Tablets and \(c\) Compasses, that player gets \(a^2 + b^2 + c^2 + 7 \cdot \min(a, b, c)\) 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 \(2\) Cogs, \(1\) Tablet, \(2\) Compasses, and \(1\) Wildcard Science, so could thus choose to have the distributions \((3, 1, 2), (2, 2, 2)\) or \((2, 1, 3)\) of Cogs, Tablets and Compasses, respectively. The possible scores for this player are then \(3^2 + 1^2 + 2^2 + 7 \cdot 1 = 21\), \(2^2 + 2^2 + 2^2 + 7 \cdot 2 = 26\) and \(2^2 + 1^2 + 3^2 + 7 \cdot 1 = 21\) depending on how the Wildcard Science is assigned. Thus, the maximum score for this player is \(26\).

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.

제약
입력 형식

The input consists of:
- One line with an integer \(n\) (\(3 \le n \le 7\)), the number of players in the game.
- \(n\) lines, each with four integers \(a\), \(b\), \(c\), \(d\) (\(0 \le a, b, c, d \le 10^9\)), giving the number of Cog, Tablet, Compass, and Wildcard Science tokens of a player.

출력 형식

For each player, in the same order they are given in the input, output the maximum score the player may get.

예제 1
입력
3
2 1 2 1
3 2 1 0
1 3 0 1
출력
26
21
18
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NWERC 2017

평가 및 의견

H. High Score

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

H. High Score

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8