A12352 | Mishka and the Last Exam
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Mishka is trying really hard to avoid being kicked out of the university. In particular, he was doing absolutely nothing for the whole semester, miraculously passed some exams so that just one is left.
There were $n$ classes of that subject during the semester and on $i$ -th class professor mentioned some non-negative integer $a_i$ to the students. It turned out, the exam was to tell the whole sequence back to the professor.
Sounds easy enough for those who attended every class, doesn't it?
Obviously Mishka didn't attend any classes. However, professor left some clues on the values of $a$ to help out students like Mishka:
- $a$ was sorted in non-decreasing order ( $a_1 \le a_2 \le \dots \le a_n$ );
- $n$ was even;
- the following sequence $b$ , consisting of $\frac n 2$ elements, was formed and given out to students: $b_i = a_i + a_{n - i + 1}$ .
Professor also mentioned that any sequence $a$ , which produces sequence $b$ with the presented technique, will be acceptable.
Help Mishka to pass that last exam. Restore any sorted sequence $a$ of non-negative integers, which produces sequence $b$ with the presented technique. It is guaranteed that there exists at least one correct sequence $a$ , which produces the given sequence $b$ .
There were $n$ classes of that subject during the semester and on $i$ -th class professor mentioned some non-negative integer $a_i$ to the students. It turned out, the exam was to tell the whole sequence back to the professor.
Sounds easy enough for those who attended every class, doesn't it?
Obviously Mishka didn't attend any classes. However, professor left some clues on the values of $a$ to help out students like Mishka:
- $a$ was sorted in non-decreasing order ( $a_1 \le a_2 \le \dots \le a_n$ );
- $n$ was even;
- the following sequence $b$ , consisting of $\frac n 2$ elements, was formed and given out to students: $b_i = a_i + a_{n - i + 1}$ .
Professor also mentioned that any sequence $a$ , which produces sequence $b$ with the presented technique, will be acceptable.
Help Mishka to pass that last exam. Restore any sorted sequence $a$ of non-negative integers, which produces sequence $b$ with the presented technique. It is guaranteed that there exists at least one correct sequence $a$ , which produces the given sequence $b$ .
输入格式
The first line contains a single integer $n$ ( $2 \le n \le 2 \cdot 10^5$ ) — the length of sequence $a$ . $n$ is always even.
The second line contains $\frac n 2$ integers $b_1, b_2, \dots, b_{\frac n 2}$ ( $0 \le b_i \le 10^{18}$ ) — sequence $b$ , where $b_i = a_i + a_{n - i + 1}$ .
It is guaranteed that there exists at least one correct sequence $a$ , which produces the given sequence $b$ .
The second line contains $\frac n 2$ integers $b_1, b_2, \dots, b_{\frac n 2}$ ( $0 \le b_i \le 10^{18}$ ) — sequence $b$ , where $b_i = a_i + a_{n - i + 1}$ .
It is guaranteed that there exists at least one correct sequence $a$ , which produces the given sequence $b$ .
输出格式
Print $n$ integers $a_1, a_2, \dots, a_n$ ( $0 \le a_i \le 10^{18}$ ) in a single line.
$a_1 \le a_2 \le \dots \le a_n$ should be satisfied.
$b_i = a_i + a_{n - i + 1}$ should be satisfied for all valid $i$ .
$a_1 \le a_2 \le \dots \le a_n$ should be satisfied.
$b_i = a_i + a_{n - i + 1}$ should be satisfied for all valid $i$ .
输入输出样例
输入 #1
4 5 6
输出 #1
2 3 3 3
输入 #2
6 2 1 2
输出 #2
0 0 1 1 1 2
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted