given an exhibit An of length N loads of masses A1, A2...AN. No two loads have a similar mass. You can put each weight on one side of the equilibrium (left or right). You don't need to put weights in request A1,...,AN. There is additionally a string S consisting of characters "L" and "R", meaning that subsequent to putting
Correct and detailed answer will upvoted else downvoted . Skip if you don't know.
You are given an exhibit An of length N loads of masses A1, A2...AN. No two loads have a similar mass. You can put each weight on one side of the equilibrium (left or right). You don't need to put weights in request A1,...,AN. There is additionally a string S consisting of characters "L" and "R", meaning that subsequent to putting the i−th weight (not
Input :The principal line contains one integer N (1≤N≤2∗105) - the length of the cluster A The subsequent line contains N unmistakable integers: A1, A2,...,AN (1≤Ai≤109) - the loads given The third line contains string S of length N consisting only of letters "L" and "R" -string figuring out which side of the equilibrium ought to be heavier in the wake of putting your preferred i−th weight
Output :The output contains N lines. In each line, you should print one integer and one letter - integer addressing the weight you are putting on the equilibrium in that move and the letter addressing the side of the equilibrium where you are putting the weight. In case there is no arrangement, print −1.
Step by step
Solved in 4 steps with 1 images