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;
}

Codeforces Round 56-C. Mishka and the Last Exam(思维+贪心)的更多相关文章

  1. Codeforces Round #768 (Div. 2) D. Range and Partition // 思维 + 贪心 + 二分查找

    The link to problem:Problem - D - Codeforces   D. Range and Partition  time limit per test: 2 second ...

  2. Educational Codeforces Round 56 (Rated for Div. 2) ABCD

    题目链接:https://codeforces.com/contest/1093 A. Dice Rolling 题意: 有一个号数为2-7的骰子,现在有一个人他想扔到几就能扔到几,现在问需要扔多少次 ...

  3. Educational Codeforces Round 56 (Rated for Div. 2)

    涨rating啦.. 不过话说为什么有这么多数据结构题啊,难道是中国人出的? A - Dice Rolling 傻逼题,可以用一个三加一堆二或者用一堆二,那就直接.. #include<cstd ...

  4. Educational Codeforces Round 56 Solution

    A. Dice Rolling 签到. #include <bits/stdc++.h> using namespace std; int t, n; int main() { scanf ...

  5. Codeforces Round #521 (Div. 3) E. Thematic Contests(思维)

    Codeforces Round #521 (Div. 3)  E. Thematic Contests 题目传送门 题意: 现在有n个题目,每种题目有自己的类型要举办一次考试,考试的原则是每天只有一 ...

  6. Multidimensional Queries(二进制枚举+线段树+Educational Codeforces Round 56 (Rated for Div. 2))

    题目链接: https://codeforces.com/contest/1093/problem/G 题目: 题意: 在k维空间中有n个点,每次给你两种操作,一种是将某一个点的坐标改为另一个坐标,一 ...

  7. Educational Codeforces Round 56 (Rated for Div. 2) D. Beautiful Graph 【规律 && DFS】

    传送门:http://codeforces.com/contest/1093/problem/D D. Beautiful Graph time limit per test 2 seconds me ...

  8. Educational Codeforces Round 56 (Rated for Div. 2) D

    给你一个无向图 以及点的个数和边  每个节点只能用1 2 3 三个数字 求相邻 两个节点和为奇数   能否构成以及有多少种构成方法 #include<bits/stdc++.h> usin ...

  9. Educational Codeforces Round 56 Div. 2 翻车记

    A:签到. B:仅当只有一种字符时无法构成非回文串. #include<iostream> #include<cstdio> #include<cmath> #in ...

随机推荐

  1. BZOJ 1529 [POI2005]ska Piggy banks:并查集

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1529 题意: Byteazar有N个小猪存钱罐. 每个存钱罐只能用钥匙打开或者砸开. By ...

  2. 改善C#程序的建议10:用Parallel简化Task

    在命名空间System.Threading.Tasks下,有一个静态类Parallel简化了在同步状态下的Task的操作.Parallel主要提供了3个有用的方法:For.ForEach.Invoke ...

  3. 插件_热部署_JRebel

    一.License Server 1.运行反向代理 GitHub地址:https://github.com/ilanyu/ReverseProxy 下载地址:ReverseProxy_windows_ ...

  4. dead reckoning variation

    Targeting A target is a structure of information that describes the state, and change of state, of a ...

  5. nginx版本策略

    近期Nginx发布了1.17.0主线版本与1.16.0稳定版本,并且发布了一篇文章< Introducing NGINX 1.16 and 1.17 >说明Nginx的版本更新策略.推荐分 ...

  6. [转]Javascript高性能动画与页面渲染

    No setTimeout, No setInterval 作者 李光毅 发布于 2014年4月30日 如果你不得不使用setTimeout或者setInterval来实现动画,那么原因只能是你需要精 ...

  7. C#支持从自定义日期时间格式到DateTime类型

            /// <summary>         ///         /// </summary>         /// <param name=&quo ...

  8. AI-Info-Micron-Solutions-Menu:Solutions

    ylbtech-AI-Info-Micron-Solutions-Menu:Solutions 1.返回顶部 1. 按应用分类 汽车解决方案 美光科技不仅是你的存储提供商,更是你的长期合作伙伴.我们提 ...

  9. shell expr 的使用注意事项

    #!/bin/bash a=10 b=20 c=`expr $a + $b` echo "a + b :$c" c='expr $a + $b' echo "a + b ...

  10. ng2中的ng-content用法

    用途:1.ng-content用于在组件中嵌入内容 2.ng-content可以在组件中嵌入模板代码,方便定制可复用的组件 select属性支持css选择器,如"#id",&quo ...