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;
}
}
#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;
}
}
相关文章推荐
- sicily 1443 Printer Queue
- sicily 1443 Printer Queue
- 1443. Printer Queue
- POJ 3125 && Sicily 1443 Printer Queue(模拟/队列)
- POJ 3125 && Sicily 1443 Printer Queue(模拟/队列)
- sicily 1443 Printer Queue
- sicily 1443.Printer Queue
- Sicily1443—— Printer Queue
- Sicily 1443 Printer Queue
- sicily--1443. Printer Queue
- SOJ 1443.Printer Queue
- HDOJ 1443 约瑟夫环的最新应用
- POJ 3125 Printer Queue(打印队列---模拟)
- POJ 3125 Printer Queue
- UVA - 1443 Garlands (二分+DP)
- poj 1012 & hdu 1443 Joseph(约瑟夫环变形)
- UVa 12100 - Printer Queue(模拟)
- Uva - 12100 - Printer Queue
- HDU 1443 Joseph 约瑟夫环 暴力
- hdoj Joseph 1443 (约瑟夫环&打表)