摘要:在Codeforces Round 450 (Div. 2)的C题中,需要解决一个关于移除额外数字的问题。题目要求在给定一个数字序列后,通过移除一个数字使得剩余的数字构成最大的序列。解题关键在于找到序列中的最大连续递增子序列,并判断移除哪个数字能够保持其连续性。最终目标是得到一个尽可能大的序列。
Remove Extra One
time limit per test: 2 second memory limit per test: 256 megabytes input: standard input output: standard outputYou are given a permutation p p p of length n n n. Remove one element from permutation to make the number of records the maximum possible.
We remind that in a sequence of numbers a 1 , a 2 , … , a k a_1,a_2,\dots,a_k a1,a2,…,ak the element a i a_i ai is a record if for every integer j j j ( 1 ≤ j p[mx[0]]) { // 是否为最大值 mid[i]--; mx[1] = mx[0]; mx[0] = i; } else if (mx[1] == -1 or p[i] > p[mx[1]]) { // 是否仅小于最大值 mid[mx[0]]++; mx[1] = i; } } for (int i = 0; i mid[ans] or (mid[i] == mid[ans] and p[i]
文章版权声明:除非注明,否则均为VPS857原创文章,转载或复制请以超链接形式并注明出处。
还没有评论,来说两句吧...