当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7208:Loop

题目描述
You are given an array $a$ of length $n$. You must perform exactly $k$ times operations.

For each operation,

$\bullet$ First, you select two integers $l,r$ $($$1\leq l\leq r \leq n$$)$,

$\bullet$ Second, change $a$ to $b$, satisfy :

$\ \ \ \ \circ$ For each $i$ $($$1\le i< l$$)$ , $b_i=a_i$;

$\ \ \ \ \circ$ For each $i$ $($$l\le i< r$$)$ , $b_i=a_{i+1}$;

$\ \ \ \ \circ$ $b_r=a_l$

$\ \ \ \ \circ$ For each $i$ $($$r< i\le n$$)$ , $b_i=a_i$;


Find the lexicographically largest possible array after $k$ times operations.

Array $x$ is lexicographically greater than array $y$ if there exists an index $i$ $($ $1\leq i\leq n$ $)$ such that $x_i$ $>$ $y_i$ and for every $j (1\leq j \lt i) ,$ $ x_j=y_j$.
输入解释
The first line of the input contains one integer $T$ $($$1\leq T\leq 100$ $)$ --- the number of test cases. Then $T$ test cases follow.

The first line of the test case contains two integers $n,k$ $($$1\le n,k\le 300000$$)$

The second line of the test case contains $n$ integers $a_1,a_2,...,a_n$$($$1\le a_i\le 300000$$)$

The sum of $n$ over all testcases doesn't exceed $10^{6}$.

The sum of $k$ over all testcases doesn't exceed $10^{6}$.
输出解释
For each testcase,one line contains $n$ integers ,$a_1,a_2,...,a_n$ --- the lexicographically largest possible array after $k$ times operations.

**Don‘t have spaces at the end of the line**
输入样例
2
7 3
1 4 2 1 4 2 4
5 2
4 3 5 4 5
输出样例
4 4 2 4 2 1 1
5 4 5 4 3

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7208

最后修改于 2022-09-15T06:17:24+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
5000/2500MS(Java/Others) 524288/524288K(Java/Others)