Third Group Exam
시간 제한1초메모리 제한512 MB
n개 블록 각각을 이론(x_i) 또는 실기(y_i)로 선택해 이론이 a개 이상, 실기가 b개 이상이 되도록 하면서 총점을 최대로 만든다.
문제
One teacher came up with a new format for an exam.
- The exam consists of blocks, each corresponding to one of the topics; a student receives a grade for the -th block for all from to , all grades are independent;
- A grade for each block is an integer value from to 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 blocks were graded by answering a theoretical question and at least blocks were graded by solving a practical problem;
- If the previous condition is satisfied, the final grade for the exam is calculated as the sum of grades for all blocks, that is .
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 -th block by theory will get him a grade of , and passing it by practice --- a grade of . Help him determine which blocks (at least of them) he should pass by theory and which blocks (at least ) he should pass by practice, to get the maximum possible total score for the exam.
입력
The first line of input contains three integers , and --- 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 (; ). It is guaranteed that .
The second line consists of space-separated integers --- the grades Ilya will get if he passes the blocks by answering the theory questions ().
The third line consists of integers in the same format --- the grades he will get by solving practice problems ().
출력
The first line of output must contain a single integer --- the maximum total grade that Ilya can get for the exam.
The second line must contain space-separated characters, the -th of which is 'T' if Ilya should answer theory in the -th block, and 'P' if he should solve practice. At least of the characters must be equal to 'T', and at least of them must be equal to 'P'.