QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 2048 MB Puntuación total: 100

#2639. 最高分

Estadísticas

Mårten 和 Simon 喜欢玩流行的桌游《七大奇迹》(Seven Wonders),他们刚刚结束了一局游戏。现在是计算分数的时候了。

在《七大奇迹》中,获得科学分数的途径之一是收集三种不同类型的科学代币:齿轮(Cog)、石板(Tablet)和圆规(Compass)。如果一名玩家拥有 $a$ 个齿轮、$b$ 个石板和 $c$ 个圆规,该玩家将获得 $a^2 + b^2 + c^2 + 7 \cdot \min(a, b, c)$ 分。

吉萨大金字塔;世界七大奇迹之一。图片由 Nina-no 提供,采用 CC BY-SA 3.0 协议授权。

然而,计分方式因“万能科学代币”(Wildcard Science tokens)的概念而变得复杂。对于玩家拥有的每一个万能科学代币,她都可以将其计为三种普通科学代币中的任意一种。例如,样例输入 1 中的第一位玩家拥有 2 个齿轮、1 个石板、2 个圆规和 1 个万能科学代币,因此她可以选择将齿轮、石板和圆规的分布变为 $(3, 1, 2)$、$(2, 2, 2)$ 或 $(2, 1, 3)$。根据万能科学代币的分配方式,该玩家可能的得分分别为 $3^2 + 1^2 + 2^2 + 7 \cdot 1 = 21$、$2^2 + 2^2 + 2^2 + 7 \cdot 2 = 26$ 以及 $2^2 + 1^2 + 3^2 + 7 \cdot 1 = 21$。因此,该玩家的最高得分为 26。

给定每位玩家拥有的代币数量,请计算他们在最优分配万能科学代币的情况下,每人能获得的最高得分。

输入格式

输入包含:

  • 一行一个整数 $n$ ($3 \le n \le 7$),表示游戏中的玩家人数。
  • $n$ 行,每行包含四个整数 $a, b, c, d$ ($0 \le a, b, c, d \le 10^9$),分别表示一名玩家拥有的齿轮、石板、圆规和万能科学代币的数量。

输出格式

对于每位玩家,按照输入中给出的顺序,输出该玩家可能获得的最高得分。

样例

输入格式 1

3
2 1 2 1
3 2 1 0
1 3 0 1

输出格式 1

26
21
18

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.