CF89E.Fire and Ice
省选/NOI-
通过率:0%
时间限制:0.50s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The Fire Lord attacked the Frost Kingdom. He has already got to the Ice Fortress, where the Snow Queen dwells. He arranged his army on a segment n in length not far from the city walls. And only the frost magician Solomon can save the Frost Kingdom.

The n-long segment is located at a distance equal exactly to 1 from the castle walls. It can be imaginarily divided into unit segments. On some of the unit segments fire demons are located — no more than one demon per position. Each demon is characterised by his strength - by some positive integer. We can regard the fire demons being idle.
Initially Solomon is positioned on the fortress wall. He can perform the following actions several times in a row:
- "L" — Solomon shifts one unit to the left. This movement cannot be performed on the castle wall.
- "R" — Solomon shifts one unit to the left. This movement cannot be performed if there's no ice block to the right.
- "A" — If there's nothing to the right of Solomon, then Solomon creates an ice block that immediately freezes to the block that Solomon is currently standing on. If there already is an ice block, then Solomon destroys it. At that the ice blocks to the right of the destroyed one can remain but they are left unsupported. Those ice blocks fall down.
Solomon spends exactly a second on each of these actions.
As the result of Solomon's actions, ice blocks' segments fall down. When an ice block falls on a fire demon, the block evaporates and the demon's strength is reduced by 1. When the demons' strength is equal to 0, the fire demon vanishes. The picture below shows how it happens. The ice block that falls on the position with no demon, breaks into lots of tiny pieces and vanishes without hurting anybody.

Help Solomon destroy all the Fire Lord's army in minimum time.
火之领主进攻了霜冻王国。他已抵达冰霜城堡,那里居住着雪之女王。他在距城墙恰好为 1 的位置、一条长度为 n 的线段上布下了自己的军队。而唯有霜冻法师所罗门能够拯救霜冻王国。

这条长度为 n 的线段与城堡城墙的距离恰好为 1。它可以被想象成由若干单位线段组成。某些单位线段上驻有火焰恶魔——每个位置至多有一个恶魔。每个恶魔以其力量(某个正整数)为特征。我们可以认为这些火焰恶魔目前处于闲置状态。
初始时,所罗门位于城堡城墙之上。他可以连续多次执行以下操作之一:
"L"— 所罗门向左移动一个单位。此移动在城堡城墙之上不可执行。"R"— 所罗门向右移动一个单位。若其右侧无冰块,则此移动不可执行。"A"— 若所罗门右侧为空,则他生成一块冰块,该冰块立即冻结并附着于其所站立的冰块(或城墙)上;若其右侧已存在冰块,则他将其摧毁。被摧毁的冰块右侧的冰块可能仍然存在,但将失去支撑,从而坠落。
所罗门执行每种操作均恰好耗时 1 秒。
在所罗门的操作下,冰块所在的单位线段会坠落。当一块冰块坠落到某火焰恶魔所在位置时,该冰块蒸发,且该恶魔的力量减 1;当恶魔力量降至 0 时,该火焰恶魔即消失。下图展示了这一过程:坠落到无恶魔位置的冰块会碎裂成无数微小碎片,并在不伤害任何人的情况下消失。

请帮助所罗门以最短时间消灭火之领主的全部军队。
输入格式
The first line contains an integer n (1 ≤ n ≤ 1000). The next line contains n numbers, the i-th of them represents the strength of the fire demon standing of the i-th position, an integer from 1 to 100. If there's no demon on the i-th position, then the i-th number equals to 0. It is guaranteed that the input data have at least one fire demon.
第一行包含一个整数 n(1≤n≤1000)。下一行包含 n 个数字,其中第 i 个数字表示站在第 i 个位置上的火魔的强度,该值为 1 到 100 之间的整数。若第 i 个位置上没有火魔,则第 i 个数字为 0。保证输入数据中至少存在一个火魔。
输出格式
Print a string of minimum length, containing characters "L", "R" and "A" — the succession of actions leading to the required result.
If there are several possible answers, print any of them.
输出一个最短长度的字符串,其中只包含字符 "L"、"R" 和 "A" —— 该字符串表示达成目标结果所需的一系列操作。
如果存在多个可能的答案,输出其中任意一个即可。
输入输出样例
输入#1
3 1 0 1
输出#1
ARARARALLLA
输入#2
3 0 2 0
输出#2
ARARALAARALA
输入解题思路,AI测评打分。不知道怎么写?