QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#15852. HIIT

统计

Alice 为 Bob 起草了一份锻炼计划,她称之为“高强度有氧惩罚挑战”。该计划包含 $n$ 种不同的练习。由于 Bob 只是个初学者,每种练习都有一个消耗 $a_i$ 单位能量的简单版本,以及一个消耗 $b_i$ 单位能量的高强度版本。对于每种练习,Bob 必须决定是进行简单版本、进行高强度版本,还是今天跳过该练习。

Bob 今天最多能消耗 $x$ 单位能量;超过这个数值他就会,呃,挂掉。Alice 最看重的是 Bob 不要挂掉。其次,Alice 希望 Bob 跳过的练习尽可能少。再次,Alice 希望 Bob 进行的高强度练习尽可能多。

Bob 现在太累了,无法思考,所以让我们帮他制定一个能让 Alice 最开心的计划吧!

输入格式

第一行包含两个空格分隔的整数 $n$ 和 $x$。

第二行包含 $n$ 个空格分隔的整数 $a_1, a_2, \dots, a_n$,表示各练习简单版本的能量消耗。

第三行包含 $n$ 个空格分隔的整数 $b_1, b_2, \dots, b_n$,表示各练习高强度版本的能量消耗。

数据范围

  • $1 \le n \le 2 \cdot 10^5$
  • $1 \le a_i < b_i \le 10^9$ 对于每个 $i$
  • $1 \le x \le 10^{15}$

输出格式

输出一个长度为 $n$ 的字符串,表示 Bob 对每项练习的选择。

  • 如果第 $i$ 个字符是 0,则 Bob 跳过第 $i$ 项练习(消耗 $0$ 单位能量)。
  • 如果第 $i$ 个字符是 1,则 Bob 进行第 $i$ 项练习的简单版本(消耗 $a_i$ 单位能量)。
  • 如果第 $i$ 个字符是 2,则 Bob 进行第 $i$ 项练习的高强度版本(消耗 $b_i$ 单位能量)。

如果满足以下所有条件,你的解将被接受:

  • 总消耗能量应 $\le x$。
  • 在所有消耗能量 $\le x$ 的方案中,0 的数量应最小化。
  • 在所有消耗能量 $\le x$ 且 0 的数量最小的方案中,2 的数量应最大化。

如果存在多种可能的解,输出其中任意一个即可。

样例

输入 1

4 6
1 5 2 1
3 7 3 4

输出 1

1021

输入 2

5 44
14 11 12 15 8
15 18 17 18 16

输出 2

20021

输入 3

5 15
1 2 3 4 5
2 3 4 5 6

输出 3

11111

输入 4

5 99
100 101 102 103 104
105 106 107 108 109

输出 4

00000

说明

对于第一个样例输入,2011 也是一个可接受的解。

第二个样例输入除了给出的解之外,还有许多其他可接受的解。

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.