E - Sequence in the Pocket

Posted _23_

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了E - Sequence in the Pocket相关的知识,希望对你有一定的参考价值。

传送门:Sequence in the Pocket

Sample Input

2
4
1 3 2 4
5
2 3 3 5 5

Sample Output

2
0


代码:

#include<bits/sdc++.h>
using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--){
        int a,b,c,d,m;
        scanf("%d",&a);
        m=0;
        int A[a+5];
        int B[a+5];
        int C[a+5];
        memset(A,0,sizeof(A));
        memset(B,0,sizeof(B));
        memset(C,0,sizeof(C));
        for(int i=0;i<a;i++){
            scanf("%d",&A[i]);
        }
        b=c=0;
        for(int i=0;i<a;i++){
            if(b==0||B[b-1]<=A[i]){
                B[b++]=A[i];
            }else{
                c++;
                m=max(m,A[i]);
            }
        }
        d=c;
        for(int i=0;i<b;i++){
            if(B[i]<m)
                d++;
            else
                break;
        }
        printf("%d\\n",d);
    }
    return 0;
}

以上是关于E - Sequence in the Pocket的主要内容,如果未能解决你的问题,请参考以下文章

1. MissingInteger 最小遗失整数 Find the minimal positive integer not occurring in a given sequence.

translation of the paper sequence and structure conservation in a protein core

Codeforces 1059E. Split the Tree

Codeforces Round #384 (Div. 2) B. Chloe and the sequence(规律题)

[Mathematics][Linear Algebra] The Rotation of the Base Vector in 3 dimensions

e614. Setting the Initial Focused Component in a Window