QOJ.ac

QOJ

時間限制: 3.0 s 記憶體限制: 1024 MB 總分: 100

#10010. 孩子们与序列游戏

统计

Alice 和 Bob 正在玩一个名为 Binary Game 的游戏。初始时,有一个包含 $n$ 个正整数的序列 $a_1, a_2, \dots, a_n$。玩家轮流进行操作,Alice 先手。在每一轮中,玩家执行以下操作:

  • 选择一个整数 $i$ ($1 \le i \le n$),使得 $a_i > 0$。然后获得 $(a_i \bmod 2)$ 分,并将 $a_i$ 更新为 $a_i := \lfloor \frac{a_i}{2} \rfloor$。

当序列中所有整数都变为 0 时,游戏结束。游戏的结果定义为 $A - B$,其中 $A$ 是 Alice 的得分,$B$ 是 Bob 的得分。Alice 的目标是最大化该结果,而 Bob 的目标是最小化该结果。若双方均采取最优策略,游戏的结果是多少?

第一行包含一个整数 $n$ ($1 \le n \le 5 \cdot 10^4$)。

第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i < 2^{63}$)。

输出一个整数:双方均采取最优策略时,游戏的结果(Alice 的得分减去 Bob 的得分)。

样例

输入格式 1

5
13 29 10 1 26

输出格式 1

3

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#879EditorialOpen题解Milmon2026-01-29 15:13:33View

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.