A9340 | New Year Present
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The New Year is coming! That's why many people today are busy preparing New Year presents. Vasily the Programmer is no exception.
Vasily knows that the best present is (no, it's not a contest) money. He's put $n$ empty wallets from left to right in a row and decided how much money to put in what wallet. Vasily decided to put $a_{i}$ coins to the $i$ -th wallet from the left.
Vasily is a very busy man, so the money are sorted into the bags by his robot. Initially, the robot stands by the leftmost wallet in the row. The robot can follow instructions of three types: go to the wallet that is to the left of the current one (if such wallet exists), go to the wallet that is to the right of the current one (if such wallet exists), put a coin to the current wallet. Due to some technical malfunctions the robot cannot follow two "put a coin" instructions in a row.
Vasily doesn't want to wait for long, so he wants to write a program for the robot that contains at most $10^{6}$ operations (not necessarily minimum in length) the robot can use to put coins into the wallets. Help him.
Vasily knows that the best present is (no, it's not a contest) money. He's put $n$ empty wallets from left to right in a row and decided how much money to put in what wallet. Vasily decided to put $a_{i}$ coins to the $i$ -th wallet from the left.
Vasily is a very busy man, so the money are sorted into the bags by his robot. Initially, the robot stands by the leftmost wallet in the row. The robot can follow instructions of three types: go to the wallet that is to the left of the current one (if such wallet exists), go to the wallet that is to the right of the current one (if such wallet exists), put a coin to the current wallet. Due to some technical malfunctions the robot cannot follow two "put a coin" instructions in a row.
Vasily doesn't want to wait for long, so he wants to write a program for the robot that contains at most $10^{6}$ operations (not necessarily minimum in length) the robot can use to put coins into the wallets. Help him.
输入格式
The first line contains integer $n$ $(2<=n<=300)$ — the number of wallets. The next line contains $n$ integers $a_{1},a_{2},...,a_{n}$ $(0<=a_{i}<=300)$ .
It is guaranteed that at least one $a_{i}$ is positive.
It is guaranteed that at least one $a_{i}$ is positive.
输出格式
Print the sequence that consists of $k$ $(1<=k<=10^{6})$ characters, each of them equals: "L", "R" or "P". Each character of the sequence is an instruction to the robot. Character "L" orders to move to the left, character "R" orders to move to the right, character "P" orders the robot to put a coin in the wallet. The robot is not allowed to go beyond the wallet line. In other words, you cannot give instructions "L" if the robot is at wallet 1, or "R" at wallet $n$ .
As a result of the performed operations, the $i$ -th wallet from the left must contain exactly $a_{i}$ coins. If there are multiple answers, you can print any of them.
As a result of the performed operations, the $i$ -th wallet from the left must contain exactly $a_{i}$ coins. If there are multiple answers, you can print any of them.
输入输出样例
输入 #1
2 1 2
输出 #1
PRPLRP
输入 #2
4 0 2 0 2
输出 #2
RPRRPLLPLRRRP
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted