您的位置:首页 > 产品设计 > UI/UE

1443 Printer Queue

2013-07-10 20:27 204 查看
#include<iostream>

#include<queue>

#include<algorithm>

using namespace std;

struct st

{

int k;

bool f;

}a[110];

bool cmk(st p, st q)

{

return p.k > q.k;

}

int main()

{

int t;

cin >> t;

while(t--)

{

queue<st>h;

int n , m, g = 0,cnt = 1;

cin >> n >> m;

for(int i = 0; i < n; i++)

{

cin >> a[i].k ;

if(i!=m)

a[i].f = 0;

else

a[i].f = 1;

h.push(a[i]);

}

sort(a,a+n,cmk);

while(h.front().k != a[g].k || !h.front().f)

{

st temp = h.front();

h.pop();

if(temp.k == a[g].k)

{

g++;

cnt++;

}

else h.push(temp);

}

cout << cnt << endl;

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: