【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

用队列和multiset就能完成模拟

【代码】

#include <bits/stdc++.h>
using namespace std; int n, m;
queue <pair<int,int> > dl;
multiset <int,greater<int> > mset; int main()
{
//freopen("F:\\rush.txt", "r", stdin);
int T;
scanf("%d", &T);
while (T--)
{
mset.clear();
while (!dl.empty()) dl.pop();
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++)
{
int x;
scanf("%d", &x);
dl.push(make_pair(x,i));
mset.insert(x);
}
int t = 0;
for (int i = 0;i < n;i++)
{
while (dl.front().first != (*mset.begin()) )
{
dl.push(dl.front());
dl.pop();
}
mset.erase(mset.begin());
t++;
if (dl.front().second == m)
{
printf("%d\n", t);
break;
}
dl.pop();
}
}
return 0;
}

【习题 5-7 UVA - 12100】Printer Queue的更多相关文章

  1. uva 12100 Printer Queue

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

  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 (习题 5-7)

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

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

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

  5. 12100 Printer Queue(优先队列)

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

  6. 【UVA】12100 Printer Queue(STL队列&优先队列)

    题目 题目     分析 练习STL     代码 #include <bits/stdc++.h> using namespace std; int main() { int t; sc ...

  7. Printer Queue UVA - 12100

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

  8. Printer Queue

    Description The only printer in the computer science students' union is experiencing an extremely he ...

  9. POJ 3125 Printer Queue

    题目: Description The only printer in the computer science students' union is experiencing an extremel ...

  10. [刷题]算法竞赛入门经典(第2版) 5-7/UVa12100 - Printer Queue

    题意:一堆文件但只有一个打印机,按优先级与排队顺序进行打印.也就是在一个可以插队的的队列里,问你何时可以打印到.至于这个插队啊,题目说"Of course, those annoying t ...

随机推荐

  1. SQLite详解,案例,手册

    SQLite 存储类型 1.NULL 2.INTEGER 3.REAL 4.TEXT 5.BLOB 创建表 CREATE TABLE COMPANY( ID INT PRIMARY KEY NOT N ...

  2. 7.Web Service 调用天气代码

    1. 2500多个城市天气预报 WEB服务公用事业 Endpoint:http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx Disco: ...

  3. CentOS下编译安装PHP5.6

    目录 1 安装php依赖的扩展 2 下载解压PHP 3 编译PHP 4 让Apache支持PHP 5 测试安装  安装php依赖的扩展: yum install -y libxml2-devel op ...

  4. Active Data Guard

    ADG INTRODUCE Active Data Guard(ADG)是ORACLE 11g企业版的新特性,需要单独的License.可以打开Physical standby至read only模式 ...

  5. svn: Can&#39;t convert string from &#39;UTF-8&#39; to native encoding 解决的方法

    今天在down代码时遇到了例如以下问题: [xxx@xxx ~]$ svn co https://xxxxxxxxxxxxx svn: Can't convert string from 'UTF-8 ...

  6. regular-第一课(正则表达式基础)

    之前一直听说正则表达式,尤其是在学习java的时候,遇到了不少关于正则表达式的用法.例如一个输入框,你可以使用正则表达式限制输入的内容.当然,在android以后,正则表达式就几乎没有怎么用了.不过呢 ...

  7. 1.4 Ecosystem官网剖析(博主推荐)

    不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ 1.4 Ecosystem 生态系统 There are a plethora of ...

  8. jmeter--FTP测试

    FTP服务主要提供上传和下载功能.有时间需要我们测试服务器上传和下载的性能.在这里我通过JMeter做一个FTP测试计划的例子. 当然,JMeter官方网站的用户手册也有例子,但由于版本较早,我也算是 ...

  9. javafx image button

    public class EffectTest extends Application { public static void main(String[] args) { launch(args); ...

  10. DG动态性能视图详解

    V$LOG 显示CONTROLFILE记录的LOG FILE信息. 列名          描述 GROUP#        日志组号 THREAD#       日志线程号 SEQUENCE#    ...