QOJ.ac

QOJ

时间限制: 1 s 内存限制: 512 MB 总分: 100 可 Hack ✓

#1901. 第三组考试

统计

一位老师想出了一种新的考试形式。

  • 考试包含 $n$ 个模块,每个模块对应一个主题;学生对于每个 $i$(从 $1$ 到 $n$),都会获得第 $i$ 个模块的成绩 $c_i$,所有成绩相互独立;
  • 每个模块的成绩是 $0$ 到 $100$ 之间的整数。学生可以选择一种方式来获得该模块的成绩:回答理论问题或解决实际问题;
  • 如果至少有 $a$ 个模块是通过回答理论问题评分的,且至少有 $b$ 个模块是通过解决实际问题评分的,则考试通过;
  • 如果满足上述条件,考试的最终成绩 $C$ 计算为所有模块成绩之和,即 $C = \sum_{i=1}^{n} c_i$。

Ilya 即将参加这场考试。他对自己每个主题的知识水平有很好的了解,他确定通过理论方式通过第 $i$ 个模块将获得成绩 $x_i$,通过实践方式通过第 $i$ 个模块将获得成绩 $y_i$。请帮助他确定应该通过理论方式通过哪些模块(至少 $a$ 个),以及通过实践方式通过哪些模块(至少 $b$ 个),以使考试的总分最高。

输入格式

第一行包含三个整数 $n, a$ 和 $b$ —— 分别表示主题总数、通过理论方式通过的最少主题数以及通过实践方式通过的最少主题数($1 \le n \le 2 \cdot 10^5$;$0 \le a, b \le n$)。保证 $a + b \le n$。

第二行包含 $n$ 个空格分隔的整数 $x_i$ —— Ilya 通过回答理论问题获得的成绩($0 \le x_i \le 100$)。

第三行包含 $n$ 个空格分隔的整数 $y_i$ —— Ilya 通过解决实际问题获得的成绩($0 \le y_i \le 100$)。

输出格式

第一行必须包含一个整数 $C$ —— Ilya 在考试中能获得的最高总分。

第二行必须包含 $n$ 个空格分隔的字符,其中第 $i$ 个字符如果是 'T',表示 Ilya 应该在第 $i$ 个模块中回答理论问题;如果是 'P',表示他应该解决实际问题。字符中至少有 $a$ 个 'T',且至少有 $b$ 个 'P'。

样例

样例输入 1

4 1 1
10 30 50 70
80 60 40 20

样例输出 1

260
P P T T

样例输入 2

4 1 1
30 40 60 90
10 25 50 85

样例输出 2

215
T T T P

样例输入 3

4 2 1
0 17 70 13
2 21 55 99

样例输出 3

190
T P T P

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.