繁华模拟赛 摆书
Posted ACforever
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了繁华模拟赛 摆书相关的知识,希望对你有一定的参考价值。
#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\n",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")))
以上是关于繁华模拟赛 摆书的主要内容,如果未能解决你的问题,请参考以下文章