Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
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. The first line contains one integer (N) ((1 \leq N \leq 2*10^5)) - the length of the array (A) The second line contains (N) distinct integers: (A_1), (A_2),...,(A_N) ((1 \leq A_i \leq 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 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). 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. |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
131343252 |
hos.lyric |
A |
Oct. 9, 2021, 3:25 p.m. |
OK |
D |
TESTS |
50 |
249 |
18227200 |
|
|
|
131376399 |
XueYJ |
A |
Oct. 10, 2021, 4:12 a.m. |
OK |
GNU C++14 |
TESTS |
50 |
109 |
6348800 |
|
|
|
131312864 |
wh2005 _Wallace_61430 STUPID_JUSTIN |
A |
Oct. 9, 2021, 10:34 a.m. |
OK |
GNU C++14 |
TESTS |
50 |
124 |
5120000 |
|
|
|
131314352 |
FrostStar oipotato chenjb |
A |
Oct. 9, 2021, 10:46 a.m. |
OK |
GNU C++14 |
TESTS |
50 |
124 |
6348800 |
|
|
|
131329677 |
zhoumofei Zhu_Xiangyu zaozao_zmx1 |
A |
Oct. 9, 2021, 1 p.m. |
OK |
GNU C++14 |
TESTS |
50 |
124 |
8704000 |
|
|
|
131374276 |
tujunbo |
A |
Oct. 10, 2021, 3:13 a.m. |
OK |
GNU C++14 |
TESTS |
50 |
140 |
5017600 |
|
|
|
131370408 |
shb123 |
A |
Oct. 10, 2021, 12:46 a.m. |
OK |
GNU C++14 |
TESTS |
50 |
140 |
8601600 |
|
|
|
131339907 |
BlueDiamond |
A |
Oct. 9, 2021, 2:46 p.m. |
OK |
GNU C++14 |
TESTS |
50 |
155 |
9523200 |
|
|
|
131374590 |
minsiqi |
A |
Oct. 10, 2021, 3:22 a.m. |
OK |
GNU C++14 |
TESTS |
50 |
171 |
4710400 |
|
|
|
131312014 |
Cornflakes leapfrog DPair |
A |
Oct. 9, 2021, 10:27 a.m. |
OK |
GNU C++14 |
TESTS |
50 |
171 |
6553600 |
|
|
|
131302580 |
juju527 huangzirui xiaoziyao |
A |
Oct. 9, 2021, 9:13 a.m. |
OK |
GNU C++14 |
TESTS |
50 |
187 |
9113600 |
|
|
|
131344565 |
semiexp |
A |
Oct. 9, 2021, 3:42 p.m. |
OK |
GNU C++17 |
TESTS |
50 |
109 |
6348800 |
|
|
|
131373581 |
Neal_lee |
A |
Oct. 10, 2021, 2:53 a.m. |
OK |
GNU C++17 |
TESTS |
50 |
109 |
7270400 |
|
|
|
131373072 |
CuCl2 |
A |
Oct. 10, 2021, 2:40 a.m. |
OK |
GNU C++17 |
TESTS |
50 |
124 |
5529600 |
|
|
|
131374068 |
DerekFeng |
A |
Oct. 10, 2021, 3:07 a.m. |
OK |
GNU C++17 |
TESTS |
50 |
124 |
6451200 |
|
|
|
131374496 |
sjc061031 |
A |
Oct. 10, 2021, 3:19 a.m. |
OK |
GNU C++17 |
TESTS |
50 |
124 |
10035200 |
|
|
|
131314080 |
Hollowed fextivity xuanquang1999 |
A |
Oct. 9, 2021, 10:44 a.m. |
OK |
GNU C++17 |
TESTS |
50 |
124 |
10342400 |
|
|
|
131313720 |
Cirno_9baka ChthollyNotaSeniorious JeovaSantusUnus |
A |
Oct. 9, 2021, 10:41 a.m. |
OK |
GNU C++17 |
TESTS |
50 |
124 |
16793600 |
|
|
|
131311473 |
lindongli2004 qazswedx2 Chameleon216 |
A |
Oct. 9, 2021, 10:22 a.m. |
OK |
GNU C++17 |
TESTS |
50 |
124 |
16793600 |
|
|
|
131312375 |
lucaperju ivan.tudor Kripton2005 |
A |
Oct. 9, 2021, 10:29 a.m. |
OK |
GNU C++17 |
TESTS |
50 |
139 |
6860800 |
|
|
|
131307892 |
AaParsa alireza_kaviani |
A |
Oct. 9, 2021, 9:55 a.m. |
OK |
GNU C++17 |
TESTS |
50 |
140 |
6041600 |
|
|
|
131348472 |
yosupo |
A |
Oct. 9, 2021, 4:33 p.m. |
OK |
GNU C++17 (64) |
TESTS |
50 |
46 |
8908800 |
|
|
|
131374430 |
burnoutag |
A |
Oct. 10, 2021, 3:17 a.m. |
OK |
GNU C++17 (64) |
TESTS |
50 |
93 |
5324800 |
|
|
|
131371243 |
errorgorn |
A |
Oct. 10, 2021, 1:32 a.m. |
OK |
GNU C++17 (64) |
TESTS |
50 |
93 |
5836800 |
|
|
|
131371541 |
dqhungdl |
A |
Oct. 10, 2021, 1:45 a.m. |
OK |
GNU C++17 (64) |
TESTS |
50 |
93 |
6348800 |
|
|
|
131304199 |
_runtimeTerror_ DenOMINATOR rivalq |
A |
Oct. 9, 2021, 9:26 a.m. |
OK |
GNU C++17 (64) |
TESTS |
50 |
93 |
6348800 |
|
|
|
131314336 |
_yui_ 77o |
A |
Oct. 9, 2021, 10:46 a.m. |
OK |
GNU C++17 (64) |
TESTS |
50 |
93 |
6553600 |
|
|
|
131303141 |
orzdevinwang |
A |
Oct. 9, 2021, 9:18 a.m. |
OK |
GNU C++17 (64) |
TESTS |
50 |
93 |
7168000 |
|
|
|
131322474 |
ArtyomTsepov reshke Friska |
A |
Oct. 9, 2021, 11:53 a.m. |
OK |
GNU C++17 (64) |
TESTS |
50 |
93 |
7577600 |
|
|
|
131337768 |
Ormlis |
A |
Oct. 9, 2021, 2:22 p.m. |
OK |
GNU C++17 (64) |
TESTS |
50 |
93 |
7987200 |
|
|
|
131369798 |
czhang2718 |
A |
Oct. 10, 2021, 12:07 a.m. |
OK |
GNU C++17 (64) |
TESTS |
50 |
93 |
9625600 |
|
|
|
131341573 |
AaParsa |
A |
Oct. 9, 2021, 3:04 p.m. |
OK |
Haskell |
TESTS |
50 |
826 |
64102400 |
|
|
|
131341466 |
AaParsa |
A |
Oct. 9, 2021, 3:03 p.m. |
OK |
Haskell |
TESTS |
50 |
951 |
63078400 |
|
|
|
131309346 |
uwi nuip maspy |
A |
Oct. 9, 2021, 10:06 a.m. |
OK |
Java 11 |
TESTS |
50 |
280 |
24371200 |
|
|
|
131335596 |
mmaxio |
A |
Oct. 9, 2021, 1:59 p.m. |
OK |
Java 11 |
TESTS |
50 |
327 |
24985600 |
|
|
|
131304304 |
tuna_salad |
A |
Oct. 9, 2021, 9:27 a.m. |
OK |
Rust |
TESTS |
50 |
78 |
10035200 |
|
|
|
131328761 |
qwerty787788 |
A |
Oct. 9, 2021, 12:52 p.m. |
OK |
Rust |
TESTS |
50 |
140 |
16281600 |
|
|
remove filters
Back to search problems