UVa12100
来源:互联网 发布:南风知我意txt免费下载 编辑:程序博客网 时间:2024/05/17 17:42
/*
关键是理解题意,如果当前取出的任务不是优先级最高的,那么就把该任务放在队列最后
注意,此时是不会打印优先级最高的任务,也不会消耗时间
*/
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<string.h>
#include<math.h>
#include<queue>
using namespace std;
int main(){
int T,n,m,x,target;
scanf("%d",&T);
while(T--){
queue<int>Q;
priority_queue<int>PQ;
scanf("%d%d",&n,&m);
for(int i=0;i<n;++i){
scanf("%d",&x);
Q.push(x);
PQ.push(x);
if(i==m)target=x;
}
int t=0;
while(!PQ.empty()&&PQ.top()>=target){
while(Q.front()!=PQ.top()){
Q.push(Q.front());
Q.pop();
m=m==0?Q.size()-1:m-1;
}
Q.pop();PQ.pop();
++t,--m;
if(m<0)break;
}
printf("%d\n",t);
}
}
阅读全文
0 0
- UVa12100
- UVa12100
- UVa12100 - Printer Queue
- UVA12100 - Printer Queue
- UVA12100-打印队列
- UVa12100 Printer Queue
- UVA12100 Printer Queue
- uva12100解题报告
- UVa12100 Printer Queue (打印队列)
- UVA12100:Printer Queue(打印队列)
- 习题5-7 打印队列 UVa12100
- UVA12100 Printer Queue 【双端队列】
- uva12100 Printer Queue (队列模拟, 据说是优先队列,错了)
- Uva12100 Printer Queue 【queue+sort】【习题5-7】
- UVALive3638 UVA12100 POJ3125 HDU1972 Printer Queue【队列+模拟】
- 习题5-7 打印队列(Printer Queue, UVa12100)
- 有关优先对列的题——UVA12100 - Printer Queue
- [刷题]算法竞赛入门经典(第2版) 5-7/UVa12100 - Printer Queue
- 新款安卓架构设计-Architecture Components介绍
- 对象克隆
- GIC-400寄存器 之CPU接口
- Android7.0中文文档(API)-- ShareActionProvider
- Solr单集代码调用案例
- UVa12100
- Let the Balloon Rise
- [mark]Chrome webdriver 下载
- [机器学习入门] 李弘毅机器学习笔记-17(Unsupervised Learning: Deep Auto-encoder;无监督学习:深度自动编码器)
- Error:Execution failed for task ':xxx:compileReleaseJavaWithJavac'.
- String、StringBuffer、StringBuilder
- Document对象,Element对象和Node对象简介
- oracle数据库锁表问题
- 反射