CF1093C.Mishka and the Last Exam

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 nn classes of that subject during the semester and on ii-th class professor mentioned some non-negative integer aia_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 aa to help out students like Mishka:

  • aa was sorted in non-decreasing order (a1≤a2≤⋯≤ana_1 \le a_2 \le \dots \le a_n);
  • nn was even;
  • the following sequence bb, consisting of n2\frac n 2 elements, was formed and given out to students: bi=ai+an−i+1b_i = a_i + a_{n - i + 1}.

Professor also mentioned that any sequence aa, which produces sequence bb with the presented technique, will be acceptable.

Help Mishka to pass that last exam. Restore any sorted sequence aa of non-negative integers, which produces sequence bb with the presented technique. It is guaranteed that there exists at least one correct sequence aa, which produces the given sequence bb.

米什卡正竭尽全力避免被大学开除。特别是,整个学期他完全无所事事,却奇迹般地通过了若干门考试,目前仅剩最后一门尚未通过。

该课程在本学期共开设了 nn 节课,第 ii 节课上,教授向学生们提到了某个非负整数 aia_i。结果,期末考试的内容就是将整个序列 aa 完整地复述给教授。

对那些每节课都出席的学生来说,这听起来很简单,不是吗?

显然,米什卡一节课都没上。不过,教授留下了一些关于序列 aa 的线索,以帮助像米什卡这样的学生:

  • 序列 aa 是按非递减顺序排列的(即 a1≤a2≤⋯≤ana_1 \le a_2 \le \dots \le a_n);
  • nn 是偶数;
  • 构造了一个由 n2\frac{n}{2} 个元素组成的序列 bb 并分发给了学生:bi=ai+an−i+1b_i = a_i + a_{n - i + 1}。

教授还特别说明:任何能通过上述方法生成给定序列 bb 的序列 aa 均可被接受。

请帮助米什卡通过这最后一门考试。恢复出任意一个满足条件的、由非负整数组成的非递减序列 aa,使其能通过上述方法生成给定的序列 bb。题目保证至少存在一个正确的序列 aa 能生成给定的序列 bb。

输入格式

The first line contains a single integer nn (2≤n≤2⋅1052 \le n \le 2 \cdot 10^5) — the length of sequence aa. nn is always even.

The second line contains n2\frac n 2 integers b1,b2,…,bn2b_1, b_2, \dots, b_{\frac n 2} (0≤bi≤10180 \le b_i \le 10^{18}) — sequence bb, where bi=ai+an−i+1b_i = a_i + a_{n - i + 1}.

It is guaranteed that there exists at least one correct sequence aa, which produces the given sequence bb.

第一行包含一个整数 nn(2≤n≤2⋅1052 \le n \le 2 \cdot 10^5)——序列 aa 的长度。nn 总是偶数。

第二行包含 n2\frac n 2 个整数 b1,b2,…,bn2b_1, b_2, \dots, b_{\frac n 2}(0≤bi≤10180 \le b_i \le 10^{18})——序列 bb,其中 bi=ai+an−i+1b_i = a_i + a_{n - i + 1}。

保证至少存在一个正确的序列 aa,能够生成给定的序列 bb。

输出格式

Print nn integers a1,a2,…,ana_1, a_2, \dots, a_n (0≤ai≤10180 \le a_i \le 10^{18}) in a single line.

a1≤a2≤⋯≤ana_1 \le a_2 \le \dots \le a_n should be satisfied.

bi=ai+an−i+1b_i = a_i + a_{n - i + 1} should be satisfied for all valid ii.

在一行中输出 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(其中 0≤ai≤10180 \le a_i \le 10^{18})。

需满足 a1≤a2≤⋯≤ana_1 \le a_2 \le \dots \le a_n。

对所有合法的 ii,需满足 bi=ai+an−i+1b_i = a_i + a_{n - i + 1}。

输入输出样例

  • 输入#1

    4
    5 6

    输出#1

    2 3 3 3
  • 输入#2

    6
    2 1 2

    输出#2

    0 0 1 1 1 2

输入解题思路,AI测评打分。不知道怎么写?

首页