아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Third Group Exam

시간 제한1초메모리 제한512 MB

요약
n개 블록 각각을 이론(x_i) 또는 실기(y_i)로 선택해 이론이 a개 이상, 실기가 b개 이상이 되도록 하면서 총점을 최대로 만든다.
난이도

보통10점 중 5점

유형
그리디, 정렬, 구현, 배열
정답자
아직 제출이 없습니다

문제

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

  • The exam consists of nn blocks, each corresponding to one of the topics; a student receives a grade c_ic\_i for the ii-th block for all ii from 11 to nn, all grades are independent;
  • A grade for each block is an integer value from 00 to 100100 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 aa blocks were graded by answering a theoretical question and at least bb blocks were graded by solving a practical problem;
  • If the previous condition is satisfied, the final grade for the exam CC is calculated as the sum of grades for all blocks, that is C=∑_i=1nc_iC = \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 ii-th block by theory will get him a grade of x_ix\_i, and passing it by practice --- a grade of y_iy\_i. Help him determine which blocks (at least aa of them) he should pass by theory and which blocks (at least bb) he should pass by practice, to get the maximum possible total score for the exam.

입력

The first line of input contains three integers nn, aa and bb --- 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⩽n⩽2⋅1051 \leqslant n \leqslant 2 \cdot 10^5; 0⩽a,b⩽n0 \leqslant a, b \leqslant n). It is guaranteed that a+b⩽na + b \leqslant n.

The second line consists of nn space-separated integers x_ix\_i --- the grades Ilya will get if he passes the blocks by answering the theory questions (0⩽x_i⩽1000 \leqslant x\_i \leqslant 100).

The third line consists nn of integers y_iy\_i in the same format --- the grades he will get by solving practice problems (0⩽y_i⩽1000 \leqslant y\_i \leqslant 100).

출력

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

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

예제3

  1. 예제 1

    입력
    4 1 1
    10 30 50 70
    80 60 40 20
    
    예상 출력
    260
    P P T T
    
  2. 예제 2

    입력
    4 1 1
    30 40 60 90
    10 25 50 85
    
    예상 출력
    215
    T T T P
    
  3. 예제 3

    입력
    4 2 1
    0 17 70 13
    2 21 55 99
    
    예상 출력
    190
    T P T P