QOJ.ac

QOJ

Límite de tiempo: 5 s Límite de memoria: 1024 MB Puntuación total: 100 Dificultad: [mostrar] Hackeable ✓

#127. 卡牌游戏策略

Estadísticas

Alice 和 Bob 准备玩一个卡牌游戏。共有 $n$ 张牌,每张牌上都写有一个整数。游戏按如下步骤进行:

  1. Alice 在 $a$ 到 $b$ 之间(包含两端)选择一个整数。称这个整数为 $t$。然后 Alice 将 $t$ 的值告诉 Bob。
  2. Bob 从这 $n$ 张牌中选择 $k$ 张牌。计算 Bob 所选的 $k$ 张牌上所写整数之和。称这个和为 $u$。

Alice 的目标是使 $|t - u|$ 尽可能大,而 Bob 的目标是使 $|t - u|$ 尽可能小。在游戏开始之前,Alice 和 Bob 都知道 $n$、$k$、$a$ 和 $b$ 的值,也知道所有牌上的整数。Alice 和 Bob 都会采取最优策略。特别地,Alice 在做出选择时知道,对于她所告知的 $t$,Bob 一定会使 $|t - u|$ 最小化。此外,假设当 Alice 有多个同样好的选择时,她倾向于选择较小的 $t$。

你的任务是确定游戏的结果:Alice 会选择的 $t$ 的值,以及对于该 $t$,Bob 会选择的 $k$ 张牌。

输入格式

输入包含两行,表示单个测试用例。第一行包含四个整数 $n$、$k$、$a$ 和 $b$($1 \le k \le n \le 600$,$0 \le a \le b \le 1.8 \cdot 10^5$)。第二行包含 $n$ 个整数 $x_1, \ldots, x_n$($0 \le x_i \le 300$),表示第 $i$ 张牌上写着 $x_i$。

输出格式

输出两行:第一行应包含一个整数,表示 Alice 会选择的 $t$ 的值。第二行应包含 $k$ 个介于 $1$ 到 $n$ 之间(包含两端)的互不相同的整数,表示 Bob 会选择的牌的编号。如果 Bob 有多个同样好的选择,输出其中任意一个即可。

样例

输入格式 1

4 2 58 100
10 10 50 80

输出格式 1

75
2 3

输入格式 2

8 3 1300 1800
2 0 1 5 0 4 1 9

输出格式 2

1800
4 6 8

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.