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

【题意】

在这里输入题意

【题解】

用队列和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. a标签中的javascript:;是什么

    a标签中的javascript:;是什么 一.问题 <a>标签中href="javascript:;"表示什么意思?? <a id="jsPswEdit ...

  2. LinkCutTree详解

    LCT详解 没有比这再详细的了, 相信我

  3. SSH远程快速登录Linux

    SSH远程快速登录Linux        使用SSH管理linux服务器,通常要使用ssh,然后输入用户,密码,其实只要配置一个文件就可以方便登录.假设要登录server域名是www.interne ...

  4. 最大子段和 模板题 51Nod 1049

    N个整数组成的序列a[1],a[2],a[3],…,a[n],求该序列如a[i]+a[i+1]+…+a[j]的连续子段和的最大值.当所给的整数均为负数时和为0. 例如:-2,11,-4,13,-5,- ...

  5. 抓包神器Fiddler之Https请求随心转

    随着AppleStore对APP的审核越来越严格,客户端请求服务端API的方式大多数都变更为了https,在更安全的同时又引起了另外一个问题——本地抓包开发调试的不便. 一般来说,我们在开发API的时 ...

  6. ZOJ 3674 Search in the Wiki(字典树 + map + vector)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4917 题意:每一个单词都一些tips单词. 先输入n个单词和他们的t ...

  7. 仙人掌的同构(hash)

    关于仙人掌的同构,主要是我太蒟蒻了QAQ,问了好几位大佬才弄好. 手撕仙人掌,你得先有手套 ,你得先了解以下基本知识 a.点双连通分量,没什么好说得,仙人掌上有环,判环用点双 b.树的hash点这里 ...

  8. 【Java学习】Font字体类的用法介绍

    一.Font类简介 Font类是用于设置图形用户界面上的字体样式的,包括字体类型(例如宋体.仿宋.Times New Roman等).字体风格(例如斜体字.加粗等).以及字号大小. 二.Font类的引 ...

  9. 自绘listCtrl控件选中该行高亮(模拟windows)

    CListCtrl的派生类CMyListCtrl的DrawItem()函数里添加代码 CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC); if ...

  10. 洛谷 P4779【模板】单源最短路径(标准版)

    洛谷 P4779[模板]单源最短路径(标准版) 题目背景 2018 年 7 月 19 日,某位同学在 NOI Day 1 T1 归程 一题里非常熟练地使用了一个广为人知的算法求最短路. 然后呢? 10 ...