time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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 aiai 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≤⋯≤ana1≤a2≤⋯≤an);
  • nn was even;
  • the following sequence bb, consisting of n2n2 elements, was formed and given out to students: bi=ai+an−i+1bi=ai+an−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.

Input

The first line contains a single integer nn (2≤n≤2⋅1052≤n≤2⋅105) — the length of sequence aa. nn is always even.

The second line contains n2n2 integers b1,b2,…,bn2b1,b2,…,bn2 (0≤bi≤10180≤bi≤1018) — sequence bb, where bi=ai+an−i+1bi=ai+an−i+1.

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

Output

Print nn integers a1,a2,…,ana1,a2,…,an (0≤ai≤10180≤ai≤1018) in a single line.

a1≤a2≤⋯≤ana1≤a2≤⋯≤an should be satisfied.

bi=ai+an−i+1bi=ai+an−i+1 should be satisfied for all valid ii.

Examples

input

Copy

4
5 6

output

Copy

2 3 3 3

input

Copy

6
2 1 2

output

Copy

0 0 1 1 1 2 

题解:

题目大意是说b[i]=a[i]+a[n-i]的值,并且要保证是递增的,我们可以想,让左边的尽可能小,并且比右边的小,我们就可以去他左边的和右边较小的最大值即可,需要注意的是数据范围是 long long int型的

代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring> using namespace std; int main()
{
int n;
cin>>n;
long long int k;
long long int a[200005];
for(int t=0;t<n/2;t++)
{
cin>>k;
if(t==0)
{
a[0]=0;
a[n-1]=k;
}
else
{
a[t]=max(a[t-1],min(a[n-t],k-a[n-t]));
a[n-1-t]=k-a[t];
}
}
for(int t=0;t<n;t++)
{
cout<<a[t]<<" ";
} return 0;
}

最新文章

  1. C#回顾 –5.反射
  2. 19. UIAlertController 提示框获取文本内容,打印控制台上
  3. cocos2dx 3.x(捕鱼达人炮台角度换算)
  4. VirtualBox没有64位选项,无法安装64位的解决方法(zhuan)
  5. 多态VI的创建
  6. Ext.Net学习笔记02:Ext.Net用法概览
  7. mongodb 查看数据库和表大小
  8. Spring IOC三种注入方式(接口注入、setter注入、构造器注入)(摘抄)
  9. HDU 1025 DP + 二分
  10. 让你的Javascript提升70%性能
  11. Mex-hdu4747(DP)
  12. 双启动:安装Windows 7 和 CentOS 7 双系统教程
  13. myeclipse 10配置jboss 7.1.1无法启动Error: Could not create the Java Virtual Machine
  14. PL/SQL常用表达式及举例(一)
  15. [LeetCode&amp;Python] Problem 807. Max Increase to Keep City Skyline
  16. Ubuntu18.04安装Python3.6.8
  17. [转]CNN目标检测(一):Faster RCNN详解
  18. webpack使用 babili-webpack-plugin 报错 &quot;original.line and original.column are not numbers&quot;
  19. 前端神器!!gulp livereload实现浏览器自动刷新
  20. 使用GraphViz画caffe网络结构图

热门文章

  1. C/C++的四大内存分区和常量的存储位置
  2. hdu-5826 physics(数学)
  3. django model中get()和filter()方法的区别
  4. visualVM远程监控JVM
  5. NOI.AC 32 Sort——分治
  6. bzoj 2067 [Poi2004]SZN——二分+贪心
  7. CentOS6.6中安装VNC server(CentOS配置远程桌面)
  8. XML常用操作
  9. [hdu3853]LOOPS(概率dp)
  10. sublime取消自动升级提示