description: You are given an array A of length N weights of masses A_1, A_2...A_N. No two weights have the same mass. You can put every weight on one side of the balance (left or right). You don't have to put weights in order A_1,...,A_N. There is also a string S consisting of characters "L" and "R", meaning that after putting the i-th weight (not A_i, but i-th weight of your choice) left or right side of the balance should be heavier. Find the order of putting the weights on the balance such that rules of string S are satisfied. 
  
  Input
  
  The first line contains one integer N (1 ≤ N ≤ 2*10^5) - the length of the array A The second line contains N distinct integers: A_1, A_2,...,A_N (1 ≤ A_i ≤ 10^9) - the weights given The third line contains string S of length N consisting only of letters "L" and "R" - string determining which side of the balance should be heavier after putting the i-th weight of your choice
  
  Output
  
  The output contains N lines. In every line, you should print one integer and one letter - integer representing the weight you are putting on the balance in that move and the letter representing the side of the balance where you are putting the weight. If there is no solution, print -1.
  
  Example
  
  Input
  
  
  5
  3 8 2 13 7
  LLRLL
  
  
  Output
  
  
  3 L
  2 R
  8 R
  13 L
  7 L
  
  Note
  
  Explanation for the test case: 
  
  after the 1st weight: 3 L (left side is heavier)
  
  after the 2nd weight: 2 R (left side is heavier)
  
  after the 3rd weight: 8 R (right side is heavier)
  
  after the 4th weight: 13 L (left side is heavier)
  
  after the 5th weight: 7 L (left side is heavier)
  
  So, the rules given by string S are fulfilled and our order of putting the weights is correct.
solution: #include <bits/stdc++.h>
  using namespace std;
  int n, a[200004], cnt;
  char s[200004];
  vector<int> vl, vr;
  int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i++)
      if (i == 1 || s[i] != s[i - 1]) cnt++;
    sort(a + 1, a + n + 1);
    for (int i = n - cnt + 1; i <= n; i++) vr.push_back(a[i]);
    for (int i = n - cnt; i; i--) vl.push_back(a[i]);
    for (int i = 0; i < vl.size(); i++) {
      if (i & 1) {
        if (s[1] == 'R') vl[i] = -vl[i];
      } else {
        if (s[1] == 'L') vl[i] = -vl[i];
      }
    }
    int cr = 0, cl = 0;
    for (int i = 1; i <= n; i++) {
      if (i == 1 || s[i] != s[i - 1])
        printf("%d %c\n", abs(vr[cr++]), s[i]);
      else {
        if (vl[cl] > 0)
          printf("%d L\n", vl[cl++]);
        else
          printf("%d R\n", -vl[cl++]);
      }
    }
  }
  