acmsguru |
---|
Finished |
H' or '
T'. If the pearl that is the i-th to take should be taken from the hanging end, then the i-th character of the string must be '
H', otherwise — '
T'. If there are multiple optimal solutions, print any of them.
sample input | sample output |
5 2 1 5 3 4 2 6 4 3 2 2 2 | 2 5 TT |
sample input | sample output |
20 7 2 3 4 8 4 8 5 6 14 5 10 3 18 2 5 2 4 1 6 3 11 4 3 3 5 2 8 4 6 9 14 7 2 7 6 6 4 8 2 10 5 | 11 60 HTHTHTHHHHH |
Step | End | Wt | Wh | S |
1 | H | 48 | 43 | 5 |
2 | T | 45 | 43 | 9 |
3 | H | 42 | 38 | 11 |
4 | T | 34 | 38 | 15 |
5 | H | 30 | 36 | 19 |
6 | T | 22 | 36 | 24 |
7 | H | 19 | 32 | 30 |
8 | H | 18 | 26 | 32 |
9 | H | 16 | 19 | 46 |
10 | H | 14 | 17 | 52 |
11 | H | 11 | 18 | 60 |
Name |
---|