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

建议使用的浏览器:

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

BZOJ4758:[Usaco2017 Jan]Subsequence Reversal

题目描述
Farmer John is arranging his NN cows in a line to take a photo (1≤N≤50). The height of the iith co
w in sequence is a(i), and Farmer John thinks it would make for an aesthetically pleasing photo if t
he cow lineup has a large increasing subsequence of cows by height.To recall, a subsequence is a sub
set a(i1),a(i2),…,a(ik)) of elements from the cow sequence, found at some series of indices i1<i2<
…<ik, We say the subsequence is increasing if a(i1)≤a(i2)≤…≤a(ik).FJ would like there to be a l
ong increasing subsequence within his ordering of the cows. In order to ensure this, he allows himse
lf initially to choose any subsequence and reverse its elements.
For example, if we had the list
1 6 2 3 4 3 5 3 4
We can reverse the chosen elements
1 6 2 3 4 3 5 3 4
  ^         ^ ^ ^
to get
1 4 2 3 4 3 3 5 6
  ^         ^ ^ ^
Observe how the subsequence being reversed ends up using the same indices as it initially occupied, 
leaving the other elements unchanged.Please find the maximum possible length of an increasing subseq
uence, given that you can choose to reverse an arbitrary subsequence once.
给定一个长度为N的序列,允许翻转一个子序列,求最长不下降子序列长度。n和数字都<=50

输入解释
The first line of input contains N. The remaining N lines contain a(1)…a(N),
each an integer in the range 1…50.

输出解释
Output the number of elements that can possibly form a longest increasing subsequence 
after reversing the contents of at most one subsequence.

输入样例
9
1
2
3
9
5
6
8
7
4
输出样例
9
提示

BZPRO Powered by Remmina.
Github Repository
来自acmore.cc的附加信息
bzoj_id 4758
import_source_sha256 89f250e9833a759da88160524621739d9018fb7ed0f234a04ec86054f822f11e
bzoj_checker_pending False

该题目包含在题集 大视野(八中)OJ 中

题目来源 BZOJ 4758

源链接: LOCAL-BZOJ4758

共提交 0 次

通过率 --%
时间上限 内存上限
10000 MS 128 MB