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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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 Ai, but i−th weight of your decision) left or right half of the equilibrium ought to be heavier. Discover the request for putting the loads on the equilibrium with the end goal that standards of string S are fulfilled. 

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.

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education