题目

题目

 


 

分析

练习STL

 


 

代码

#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,m,a[105],cnt=0;
queue <int> que;
priority_queue <int> Big;
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++) que.push(i);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
Big.push(a[i]);
}
for(;;)
{
int x=que.front();
if(a[x]==Big.top())
{
que.pop();Big.pop();
cnt++;
if(x==m) break;
}
else
{
que.pop();que.push(x);
}
}
printf("%d\n",cnt);
}
return 0;
}

【UVA】12100 Printer Queue(STL队列&优先队列)的更多相关文章

  1. uva 12100 Printer Queue 优先级队列模拟题 数组模拟队列

    题目很简单,给一个队列以及文件的位置,然后一个一个检查,如果第一个是优先级最高的就打印,否则放到队列后面,求所要打印的文件打印需要花费多长时间. 这里我用数组模拟队列实现,考虑到最糟糕的情况,必须把数 ...

  2. UVa 12100 Printer Queue(queue或者vector模拟队列)

    The only printer in the computer science students' union is experiencing an extremely heavy workload ...

  3. uva 12100 Printer Queue

    The only printer in the computer science students' union is experiencing an extremely heavy workload ...

  4. UVa 12100 Printer Queue (习题 5-7)

    传送门:https://uva.onlinejudge.org/external/121/12100.pdf 题意:队列中待打印的任务(1 <= n <= 100)带有优先级(1-9), ...

  5. 12100 Printer Queue(优先队列)

    12100 Printer Queue12 The only printer in the computer science students’ union is experiencing an ex ...

  6. Printer Queue UVA - 12100

    The only printer in the computer science students' union is experiencing an extremely heavy workload ...

  7. J - Printer Queue 优先队列与队列

    来源poj3125 The only printer in the computer science students' union is experiencing an extremely heav ...

  8. C/C++解题常用STL大礼包 含vector,map,set,queue(含优先队列) ,stack的常用用法

    每次忘记都去查,真难啊 /* C/C++解题常用STL大礼包 含vector,map,set,queue(含优先队列) ,stack的常用用法 */ /* vector常用用法 */ //头文件 #i ...

  9. UVA.540 Team Queue (队列)

    UVA.540 Team Queue (队列) 题意分析 有t个团队正在排队,每次来一个新人的时候,他可以插入到他最后一个队友的身后,如果没有他的队友,那么他只能插入到队伍的最后.题目中包含以下操作: ...

随机推荐

  1. flowable EngineConfiguration的实现分析(2)

    EngineConfiguration的实现类是一个抽象类:AbstractEngineConfiguration 一.引擎配置的分类 继承 AbsractEngineConfiguration的子类 ...

  2. 使用nrm管理npm仓库

    使用nrm管理npm仓库 用npm装包的时候,经常碰到太慢或者npm官网被墙的情况,有时候凑合一下就改一下 "~/.npmrc" 文件,但是经常改来改去也挺麻烦的,于是找到了可以使 ...

  3. Return type declarations返回类型声明

    PHP 7.新增了返回类型声明 http://php.net/manual/en/functions.returning-values.php 在PHP 7.1中新增了返回类型声明为void,以及类型 ...

  4. SpreadJS 全面支持 Angular2,V10.2 版本即将发布

    日前,纯前端表格控件 SpreadJS 发布了最新的CTP版本,在此版本中增加了对 Angular2 的支持以及一些 bug 修复. SpreadJS 纯前端表格控件是基于 HTML5 的 JavaS ...

  5. java数组实现简单的DVD管理

    package com; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Scanner; pub ...

  6. Linux系统中的一些重要的目录

    Linux系统中的一些重要的目录 1)bin目录 :基础系统所需要的命令位于此目录,是最小系统所需要的命令,如:ls, cp, mkdir等.这个目录中的文件都是可执行的,一般的用户都可以使用2)sb ...

  7. iOS调用第三方API/Framework

    前言 老板不止一次地说过:这个世纪靠个人的能力去完成一件事情肯定是不够的.无论什么方面我们都可以找到许许多多的事例表明合作共赢的重要性,例如Linux的发展.建筑事务所的发展.乃至科学技术的发展等等. ...

  8. 【javascript】如何延迟加载JavaScript(Google推荐的代码)

    下面是Google推荐的代码.这些代码应被放置在</body>标签前(接近HTML文件底部)<script type="text/javascript">f ...

  9. VC dimension and Model complexity

    可以把growth function m_H(N)的upper bound用N^(k-1)来限制, for N large, k>=3 Thus, 定义: VC Dimension: maxim ...

  10. 解决 git 错误 error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 11

    环境 Windows 7 . git push 时出现错误,无法提交代码到远程仓库. Counting objects: , done. Delta compression using up to t ...