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")))
  • 相关阅读:
    三范式最简单最易记的解释
    Mysql添加用户错误:ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value解决方法
    mysql体系结构管理
    mysql的简单操作
    flush privileges刷新MySQL的系统权限相关表
    二进制安装mysql
    扩展一台mysql-5.6.40
    mysql5.6.40部署过程
    三剑客-awk
    三剑客-sed
  • 原文地址:https://www.cnblogs.com/hyfer/p/5875117.html
Copyright © 2011-2022 走看看