题库练习 Tests for Haybales--Gold
← 上一题 下一题 →

A1022 | Tests for Haybales--Gold

来源USACO
时间限制1s
内存限制128MB
通过 / 提交0/0

题目描述

Farmer John's cows have decided to offer a programming contest for the cows on
Farmer Nhoj's farm. In order to make the problems as fun as possible, they
have spent considerable time coming up with challenging input cases. For one
problem in particular, "Haybales", the cows need your help devising
challenging inputs. This involve solving the following somewhat intriguing
problem:
There is an array of sorted integers $x_1 \leq x_2 \leq \dotsb \leq x_N$ ($1
\leq N \leq 10^5$), and an integer $K$. You don't know the array or $K$, but
you do know for each index $i$, the largest index $j_i$ such that $x_{j_i}
\leq x_i + K$. It is guaranteed that $i\le j_i$ and $j_1\le j_2\le \cdots \le
j_N\le N$.
Given this information, Farmer John's cows need to construct any array along
with some integer $K$ that matches that information. The construction needs to
satisfy $0 \leq x_i \leq 10^{18}$ for all $i$ and $1 \leq K \leq 10^{18}$.
It can be proven that this is always possible. Help Farmer John's cows solve
this problem!

输入格式

The first line of input contains $N$. The next line contains
$j_1,j_2,\ldots,j_N$.

输出格式

Print $K$, then $x_1,\ldots,x_N$ on separate lines. Any valid output will be
accepted.

输入输出样例

输入 #1
6
2 2 4 5 6 6
输出 #1
6
1
6
17
22
27
32
C++ 编辑器
输入
输出