409005: GYM103414 I Third Group Exam

Memory Limit:512 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Third Group Examtime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard output

One teacher came up with a new format for an exam.

  • The exam consists of $$$n$$$ blocks, each corresponding to one of the topics; a student receives a grade $$$c_i$$$ for the $$$i$$$-th block for all $$$i$$$ from $$$1$$$ to $$$n$$$, all grades are independent;
  • A grade for each block is an integer value from $$$0$$$ to $$$100$$$ both inclusive. A student chooses one way to get the grade for a block: to answer a theoretical question or to solve a practical problem;
  • An exam is successfully passed if at least $$$a$$$ blocks were graded by answering a theoretical question and at least $$$b$$$ blocks were graded by solving a practical problem;
  • If the previous condition is satisfied, the final grade for the exam $$$C$$$ is calculated as the sum of grades for all blocks, that is $$$C = \sum\limits_{i=1}^n c_i$$$.

Ilya is about to take the exam. He has a pretty good idea of his knowledge for each topic, and he is sure that passing the $$$i$$$-th block by theory will get him a grade of $$$x_i$$$, and passing it by practice — a grade of $$$y_i$$$. Help him determine which blocks (at least $$$a$$$ of them) he should pass by theory and which blocks (at least $$$b$$$) he should pass by practice, to get the maximum possible total score for the exam.

Input

The first line of input contains three integers $$$n$$$, $$$a$$$ and $$$b$$$ — the total number of topics, the minimum number of topics to pass by theory, and the minimum number of topics to pass by practice, respectively ($$$1 \leqslant n \leqslant 2 \cdot 10^5$$$; $$$0 \leqslant a, b \leqslant n$$$). It is guaranteed that $$$a + b \leqslant n$$$.

The second line consists of $$$n$$$ space-separated integers $$$x_i$$$ — the grades Ilya will get if he passes the blocks by answering the theory questions ($$$0 \leqslant x_i \leqslant 100$$$).

The third line consists $$$n$$$ of integers $$$y_i$$$ in the same format — the grades he will get by solving practice problems ($$$0 \leqslant y_i \leqslant 100$$$).

Output

The first line of output must contain a single integer $$$C$$$ — the maximum total grade that Ilya can get for the exam.

The second line must contain $$$n$$$ space-separated characters, the $$$i$$$-th of which is 'T' if Ilya should answer theory in the $$$i$$$-th block, and 'P' if he should solve practice. At least $$$a$$$ of the characters must be equal to 'T', and at least $$$b$$$ of them must be equal to 'P'.

ExamplesInput
4 1 1
10 30 50 70
80 60 40 20
Output
260
P P T T 
Input
4 1 1
30 40 60 90
10 25 50 85
Output
215
T T T P 
Input
4 2 1
0 17 70 13
2 21 55 99
Output
190
T P T P 

加入题单

算法标签: