poj3125 Printer Queue
来源:互联网 发布:手机淘宝怎么提交改价 编辑:程序博客网 时间:2024/04/27 12:07
模拟
#include <iostream>#include <stdio.h>#include <string.h>using namespace std;#define N 10004typedef struct node{ int pos,pri;};node q[N];int pri[10];int main(){ int n,t,m,maxx,f,r,po,ans; cin>>t; node tmp; while(t--){ cin>>n>>m; memset(pri,0,sizeof(pri)); maxx=-1; ans=0; f=0; r=n; for(int i=0;i<n;i++){ scanf("%d",&q[i].pri); q[i].pos=i; pri[q[i].pri]++; maxx=max(maxx,q[i].pri); } po=maxx; while(1){ tmp=q[f++]; if(tmp.pri<po){ q[r++]=tmp; continue; } else{ if(tmp.pos==m){ ans++; break; } else{ ans++; pri[po]--; while(!pri[po]&&po>0){ po--; } } } } printf("%d\n",ans); } return 0;}
0 0
- poj3125 Printer Queue
- poj3125——Printer Queue
- Printer Queue(打印队列)POJ3125
- Printer Queue(poj3125模拟队列)
- UVALive3638 UVA12100 POJ3125 HDU1972 Printer Queue【队列+模拟】
- POJ3125 printer(队列的使用)
- Printer Queue
- Printer Queue
- Printer Queue
- Printer Queue
- queue队列-printer queue
- poj3125
- POJ3125
- poj 3125 Printer Queue
- 1443. Printer Queue
- hoj Printer Queue
- sicily--1443. Printer Queue
- POJ 3125 Printer Queue
- [每天一个知识点]23-软件工程-有什么必要要提高生产力
- Linux内核的Nand驱动流程分析
- BP神经网络算法学习
- oracle计算时间差
- 大二寒假读书笔记150203
- poj3125 Printer Queue
- 机器学习----逻辑回归模型及求解过程[基础篇]
- 回顾-线程的创建-死锁-File的应用-UDP-TCP-反射Constructor
- MVC框架
- mybatis中的映射通过collection来封装对象的list值
- 使用系统的TabBar时,图片不显示
- 正则学习
- 菜鸟学步之磨刀石篇
- 一切成功源于积累——20150203 欧美 连续涨的致命诱惑 1H 1000点以上