Codeforces Round 450 (Div. 2) C. Remove Extra One
Remove Extra One
time limit per test: 2 second memindex.php/tags-1038.html" class="superseo">ory limit per test: 256 megabytes input: standard input output: standard output
You 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]