mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 12100_Richr_Wong.cpp
From http://blog.csdn.net/richr_wong/article/details/50190371
This commit is contained in:
parent
07a2ad9470
commit
b4c2ba60a5
57
UVA/12100_Richr_Wong.cpp
Normal file
57
UVA/12100_Richr_Wong.cpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <queue>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int n;
|
||||
cin>>n;
|
||||
for(int i=0;i<n;i++)
|
||||
{
|
||||
int num, index;
|
||||
queue<int> q;
|
||||
priority_queue<int> pq;
|
||||
cin>>num>>index;
|
||||
for(int j=0;j<num;j++)
|
||||
{
|
||||
int rate;
|
||||
cin>>rate;
|
||||
pq.push(rate);
|
||||
q.push(rate);
|
||||
}
|
||||
int x = 0;
|
||||
while(true)
|
||||
{
|
||||
if(q.front()==pq.top())
|
||||
{
|
||||
if(x==index)
|
||||
{
|
||||
cout<<num-q.size()+1<<endl;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
q.pop();
|
||||
pq.pop();
|
||||
x++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int temp = q.front();
|
||||
q.pop();
|
||||
q.push(temp);
|
||||
if(x==index)
|
||||
{
|
||||
x=0;
|
||||
index=q.size()-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user