## TLE '17 Contest 7 P6 - Base Bombing

View as PDF

Points: 25 (partial)
Time limit: 1.0s
Memory limit: 256M

Authors:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
Fax and his squadrons attacking the base.

Fax McClad, Croneria's smartest bounty hunter, has found one of the Dankey Kang Gang's bases!

The Dankey Kang Gang base is made of a straight segment of compartments numbered from to from left to right. The compartment has a strength of . Let compartment and be the space to the left of all other compartments.

Fax will attack the base using squadrons of Kyuwing bombers. Suppose Fax is over compartment . Then, Fax can issue the following commands:

• L - move to compartment . This command cannot be issued if Fax is over compartment .
• A - if there is no squadron over compartment , order a new squadron to move to compartment . If there is already squadron over compartment , then that squadron retreats, which signals all other squadrons to the right (over compartments ) to drop their bombs on the compartments they are over and retreat.
• R - move to compartment . This command can only be issued if there is a squadron over compartment .

A compartment can only take hits from bombs until it is destroyed.

Fax is initially to the left of all compartments (over compartment ).

What is the minimum number of commands that Fax must issue to destroy the base and what should they be?

#### Constraints

At least one compartment will have .

For of the points, .

#### Input Specification

The first line of input will contain .

The next line will contain integers. The integer is .

#### Output Specification

On a single line, output a string consisting of L, A, and R, denoting the commands that he should issue, in order. You may output any answer of minimum length.

#### Sample Input

3
0 0 1

#### Sample Output

ARARARALA

#### Sample Explanation

The state when following the instructions will look like this:

- - 0 0 1    - - 0 0 1    - - 0 0 1    - - 0 0 1    - - 0 0 1    - - 0 0 1    - - 0 0 1    - - 0 0 1    - - 0 0 1    - - 0 0 0
s            s            s s          s s          s s s        s s s        s s s s      s s s s      s s
^            ^              ^            ^              ^            ^              ^            ^          ^            ^

Note that compartment was not hit by bombs.

Note: If the formatting appears incorrectly, please copy and paste the characters into a text editor.