A8265 | Fire and Ice
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
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.
输出格式
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.
If there are several possible answers, print any of them.
输入输出样例
输入 #1
3 1 0 1
输出 #1
ARARARALLLA
输入 #2
3 0 2 0
输出 #2
ARARALAARALA
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted