#include<bits/stdc++.h> #define x first #define y second #define PB push_back #define mst(x,a) memset(x,a,sizeof(x)) #define all(a) begin(a),end(a) #define rep(x,l,u) for(ll x=l;x<u;x++) #define rrep(x,l,u) for(ll x=l;x>=u;x--) #define sz(x) x.size() #define IOS ios::sync_with_stdio(false);cin.tie(0); using namespace std; typedef unsigned long long ull; typedef pair<int,int> PII; typedef pair<char,char> PCC; typedef long long ll; typedef pair<ll,ll> PLL; const int N=2*1e5+10; const int M=1e5+10; const int INF=0x3f3f3f3f; const int mod=1e9+7; int a[N]; void solve(){ int n;cin>>n; rep(i,1,n+1) cin>>a[i]; if(is_sorted(a+1,a+n+1)) cout<<1<<endl; else{ int ans=0,cnt=0,cur=1,last=1; bool flag=true; rep(i,3,n+1){ if(a[i]>a[i-1]){ cur++; continue; } cnt++; if(cnt==last){ ans++; cnt=0; last=cur; cur=1; }else cur++; } cout<<ans+1<<endl; } } int main(){ IOS; //freopen("test.txt", "r", stdin); //freopen("test.txt", "w", stdout); int t;cin>>t; while(t--) solve(); return 0; }
本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。
我来说两句