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

建议使用的浏览器:

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

6592:Beauty Of Unimodal Sequence

题目描述
You are given an array of $n$ integers $a_1, a_2, ..., a_n$. We define that a sequence $p_1, p_2, ..., p_k(k \in [1,n])$ is beautiful if and only if these conditions are met:

$\quad$ $\bullet$ $1 \le p_1 < p_2<\cdots<p_k \le n. $

$\quad$ $\bullet$ There exists $t(t \in [1,k])$ satisfying $a_{p_1}<a_{p_2}<\cdots<a_{p_t}$ and $a_{p_t}>a_{p_{t+1}} > \cdots > a_{p_k}$.

You need to find all the longest beautiful sequences, and output the lexicographically smallest one and the lexicographically largest one in them.

Check the examples below for better understanding.
输入解释
There are multiple test cases.

Each case starts with a line containing a positive integer $n(n \leq 3 \times 10^5)$.

The second line contains $n$ integers $a_1, a_2, ..., a_n(1 \leq a_i \leq 10^9)$.

It is guaranteed that the sum of $N$s in all test cases is no larger than $10^6$.
输出解释
For each test case, output two lines, the first of which depicts the lexicographically smallest one in longest beautiful sequences and the second of which depicts the lexicographically largest one in longest beautiful sequences.
输入样例
7
1 4 2 5 7 4 6
3
1 2 3
3
3 2 1
输出样例
1 2 4 5 6
1 3 4 5 7
1 2 3
1 2 3
1 2 3
1 2 3
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6592

最后修改于 2020-10-25T23:32:38+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
8000/4000MS(Java/Others) 131072/131072K(Java/Others)