12100 - Printer Queue
来源:互联网 发布:尼康大竹炮数据 编辑:程序博客网 时间:2024/05/11 05:30
很简单的题。。。只要想到用list,一切轻松搞定,第一次用list,感觉针对某些题,还是很好用的~~~
#include<cstdio>
#include<string>#include<iostream>
#include<algorithm>
#include<list>
#include<queue>
using namespace std;
list<int >q;
int main()
{
int T;
scanf("%d",&T);
while(T--){
int n,m;
scanf("%d%d",&n,&m);
int t;
for(int i=0;i<n;i++){
scanf("%d",&t);
q.push_back(t);
}
// list<int>::iterator it=q.begin();
int maxn=0;
while(1){
int ans=0;
for(list<int>::iterator it=q.begin();it!=q.end();it++){
if(*it>q.front()){
q.push_back(q.front());
q.pop_front();
ans++;
if(m==0)
m=n-1;
else m--;
break;
}
}
if(ans==0){
// printf("%d\n",m);
if(m==0){
maxn++;break;
}
else{
q.pop_front();
maxn++;
n--;m--;
}
}
}
q.clear();
printf("%d\n",maxn);
}
return 0;
}
0 0
- UVa 12100 Printer Queue
- UVA - 12100 Printer Queue
- UVa 12100 - Printer Queue
- UVa 12100 - Printer Queue
- UVa: 12100 - Printer Queue
- UVa 12100 - Printer Queue
- 12100 - Printer Queue
- 12100—Printer Queue
- uva 12100 Printer Queue
- Uva - 12100 - Printer Queue
- UVA 12100 Printer Queue
- UVa 12100 - Printer Queue
- uva 12100 Printer Queue
- UVA 12100 Printer Queue
- Uva 12100 Printer Queue
- 12100-Printer Queue【STL模拟】
- UVA - 12100 Printer Queue 数组
- Printer Queue
- Web应用测试监控执行时间 -- JavaSimon
- Extremal Region(极值区域)文本定位与识别法-学习笔记(一)
- myeclipse 导入 import maven web project
- 使用AlertDialog.Builder创建对话框
- 排序练习——找出前m大的数字
- 12100 - Printer Queue
- hdu 2498 Digits
- 计算线程index
- DSAPI多功能组件编程应用-网络相关(上)
- MonkeyImage
- 2015,新的旅程
- 树结构练习——排序二叉树的中序遍历
- HDU 1754 I Hate It(线段树基础)
- poj3977