#include<iostream>
#include<vector>
using namespace std;
vector<int>queue;
int main()
{
int t;
cin >> t;
while(t--){
int n,m,x,cnt = 0;
cin >> n >> m;
while(n--){
cin >> x;
queue.push_back(x);
}
while(1){
int i ;
for( i = 0; i < queue.size(); i++)
if(queue[i] > queue[0]){
queue.push_back(queue[0]);
queue.erase(queue.begin());
if(m) m--;
else m = (int)queue.size() - 1;
i=0;
}
if(i == queue.size()){
queue.erase(queue.begin());
cnt++;
if(m) m--;
else{
cout << cnt << endl;
break;
}
}
}
queue.clear();
}
return 0;
}
UVa 12100 - Printer Queue(模拟)
最新推荐文章于 2020-08-30 18:41:19 发布