传送门:https://uva.onlinejudge.org/external/121/12100.pdf

题意:队列中待打印的任务(1 <= n <= 100)带有优先级(1-9), 打印步骤为每次从队首拿出一个, 如果队列中没有优先级比该任务高的, 打印这个任务; 若有优先级高的, 把这个任务放到队尾,  并打印优先级最高的. 每打印一次耗时1分钟, 求给定任务什么时候打印.

水题A半天    不愧是弱渣..........

最坏的情况需要maxn*maxn的空间........

front  rear  记录前后位置

 #include <bits/stdc++.h>
using namespace std; const int MAXN = ;
int t, n, m, _time;
int que[MAXN*MAXN]; void process(){
int front = , rear = n;
while(true){
int maxi = que[front];
for(int i = front; i < rear; ++i){
if(que[i] > maxi){
if(front == m) m = rear;
que[rear++] = que[front++];
break;
}
else if(i == rear - ){
++_time;
if(front == m) return ;
front++;
}
}
}
}
int main(){
cin >> t;
while(t--){
_time = ;
cin >> n >> m;
for(int i = ; i < n; ++i) cin >> que[i];
process();
cout << _time << endl;
}
return ;
}

UVa 12100 Printer Queue (习题 5-7)的更多相关文章

  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 优先级队列模拟题 数组模拟队列

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

  4. 12100 Printer Queue(优先队列)

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

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

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

  6. Printer Queue UVA - 12100

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

  7. Printer Queue

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

  8. POJ 3125 Printer Queue

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

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

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

随机推荐

  1. windows系统下快捷命令

    mstsc 远程计算机 regedit 注册表

  2. Apache server for win解压版的安装与配置

    下载地址: Apache 2.4.16 Win64位:VC14:http://www.apachelounge.com/download/VC14/binaries/httpd-2.4.16-win6 ...

  3. C# 连接 Access 数据库

    c#连接Access 数据库需要System.Data, System.Data.OleDb using System.Data using System.Data.OleDb public OleD ...

  4. java zip 批量打包(java.util包和apache.tools包)

    /** * 文件批量打包 * @param zipPath 打包路径 * @param files 批量文件 */ public void zipOut(String zipPath,File[] f ...

  5. CentOS 6.5 部署Unison双向同步服务

    环境介绍: 服务器 IP Server1 192.168.30.131 Server2 192.168.30.132       1.添加主机互信: a.添加host文件(在Server1.Serve ...

  6. 一个用于上传文件的servlet

    1.jsp页面操作文件: <%@ page language="java" import="java.util.*" pageEncoding=" ...

  7. MySql 如何实现不同数据库同步【2个】

    环境要求: Windows 操作系统 需要Mysql 3.23.15以后的版本. 假设数据库A为主机,数据库B为从机(A向B提供同步服务,即B中的数据来自A) A机器:IP=10.10.151.166 ...

  8. sulime text3

    sublime text 3 详细说明--包括快捷键 sublime 插件安装 快捷键 sunlime (需要先安装package control,ctrl+shift+p,输入insall之后安装插 ...

  9. SAP HANA创建层次结构的属性视图(Hierarchy Attribute View)

    在产品表中,数据是具有一定层次结构的 1. 在Content相应的package下面右键点击Attribute View,新建Attribute View 填写相关信息,注意:我们所建的依然是标准视图 ...

  10. IE678进入混杂模式

    <!-- 加载公共头部 --> <include file="Public/header" /> 当你在模板页的最上方加注释的说明时,在IE低版本中打开会进 ...