#include<iostream>
#include<stack>
using namespace std;
int p,k;
stack<int>s;
int ans;
int main(){
// freopen("in.txt","r",stdin);
cin>>p;
for(int t=1;t<=p;t++){
ans=0;
cin>>k;
while(!s.empty())s.pop();
s.push(0);
for(int i=1;i<=15;i++){
int a;
cin>>a;
if(a>=s.top())s.push(a);
else{
ans++;
int b=s.top();
while(b>a&&!s.empty()){
s.pop();
b=s.top();
}
s.push(a);
}
}
cout<<t<<" "<<ans<<endl;
}
return 0;
}
uva6465栈应用
最新推荐文章于 2021-09-08 08:48:21 发布