Codeforces Round 450 (Div. 2) C. Remove Extra One

慈云数据 6个月前 (05-30) 技术支持 35 0

Remove Extra One

time limit per test: 2 seCond memory 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]

微信扫一扫加客服

微信扫一扫加客服

点击启动AI问答
Draggable Icon