zoukankan      html  css  js  c++  java
  • 繁华模拟赛 摆书

     

    #include<iostream>
    #include<cstdio>
    #include<string>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    const int maxn = 100005;
    int T,n,a[maxn],cnt,ans;
    int main(){
        freopen("book.in","r",stdin);
        freopen("book.out","w",stdout);
        cin>>T;
        for(int i = 1;i <= T;i++){
            scanf("%d",&n);
            for(int j = 1;j <= n;j++){
                scanf("%d",&a[j]);
            }
            cnt = n;
            for(int j = n;j >= 1;j--) if(a[j] == cnt) cnt--;
            printf("%d
    ",cnt);
        }
        return 0;
    } 
    
    
    #include<cstdio>
    #include<iostream>
    #include<algorithm>
    #include<cstring>
    #include<cmath>
    #include<vector>
    #include<queue>
    #include<map>
    #include<set>
    #include<stack>
    #include<cstdlib>
    #include<string>
    #include<bitset>
    #define INF 1000000000
    #define N 100005
    #define fi first
    #define se second
    #define debug(x) cout<<#x<<"="<<x<<endl
    #define MP(x,y) make_pair(x,y)
    using namespace std;
    typedef long long LL;
    typedef pair<int,int> pii;
    int a[N],loc[N];
    int main()
    {
        int T,n,i;
        freopen("book.in","r",stdin);
        freopen("book.out","w",stdout);
        cin>>T;
        while(T--)
        {
            cin>>n;
            for(i=1;i<=n;i++)
                scanf("%d",&a[i]),loc[a[i]]=i;
            for(i=n;i>1;i--)
                if(loc[i]<=loc[i-1])
                    break;
            cout<<i-1<<endl;
        }
        return 0;
    }
    // davidlee1999WTK 2015/
    // srO myk Orz
    //ios::sync_with_stdio(false);
    //#pragma comment(linker, "/STACK:102400000,102400000")
    //#define O2 __attribute__((optimize("-O2")))
  • 相关阅读:
    C++——文件的读写
    我以我血荐轩辕——记徐家福教授的演讲
    文件命名
    面向对象
    关于函数
    php跨域发送请求原理以及同步异步问题
    关于iframe
    关于url
    cookie
    call和apply
  • 原文地址:https://www.cnblogs.com/hyfer/p/5875117.html
Copyright © 2011-2022 走看看