http://codeforces.com/contest/358/problem/C

将最大的放在stack里面,第二大的放在queue中,第三大的放在deck里面。然后模拟就可以了。

 #include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
int a[]; priority_queue<int ,vector<int>,less<int> >q;
int n; int main()
{
scanf("%d",&n);
for(int i=; i<=n; i++)
{
scanf("%d",&a[i]);
}
for(int i=; i<=n; i++)
{
int t1=;
int k=i;
while()
{
if(a[i]==||i==n) break;
q.push(a[i]);
i++;
}
int max1=,max2=,max3=;
if(!q.empty())
{
max1=q.top();
q.pop();
t1++;
}
if(!q.empty())
{
max2=q.top();
q.pop();
t1++;
}
if(!q.empty())
{
max3=q.top();
q.pop();
t1++;
}
for(int j=k; j<=i; j++)
{
if(a[j]==max1&&max1)
{
max1=;
printf("pushStack\n");
}
else if(a[j]==max2&&max2)
{
max2=;
printf("pushQueue\n");
}
else if(a[j]==max3&&max3)
{
max3=;
printf("pushFront\n");
}
else if(a[j]!=) printf("pushBack\n");
}
if(a[i]==)
{
if(t1==)
printf("%d\n",);
else printf("%d",t1);
if(t1>=)
{
printf(" popStack popQueue popFront\n");
}
else if(t1>=)
{
printf(" popStack popQueue\n");
}
else if(t1>=)
{
printf(" popStack\n");
}
while(!q.empty())
{
q.pop();
}
}
}
return ;
}

cf C. Dima and Containers的更多相关文章

  1. cf D. Dima and Trap Graph

    http://codeforces.com/contest/366/problem/D 遍历下界,然后用二分求上界,然后用dfs去判断是否可以. #include <cstdio> #in ...

  2. CF 366E Dima and Magic Guitar(最远哈密顿距离)

    题目链接:http://codeforces.com/problemset/problem/366/E 题意:给出一个n*m的数字矩阵A,每个矩阵元素的范围[1,K].给出一个长度为s的数字串B,B的 ...

  3. cf E. Dima and Magic Guitar

    http://codeforces.com/contest/366/problem/E |x1-x2|+|y1-y2|有四种情况 1.-(x1-x2)+(y1-y2); 2.(x1-x2)-(y1-y ...

  4. cf C. Dima and Salad

    http://codeforces.com/contest/366/problem/C 转化为背包问题,可以将a[i]-b[i]*k看成重量,a[i]为价值: 因为a[i]-b[i]*k可以为负数,所 ...

  5. cf B. Dima and To-do List

    http://codeforces.com/contest/366/problem/B 从0到k枚举起点,然后i+k判断是不是i+k>=n如果是i=(i+k)%n;否则i=i+k; #inclu ...

  6. cf D. Dima and Hares

    http://codeforces.com/contest/358/problem/D 题意:ai代表相邻的两个野兔都没有吃食物情况下的快乐系数,bi代表的是在相邻的两个野兔中有一个吃到食物的快乐系数 ...

  7. cf B. Dima and Text Messages

    http://codeforces.com/contest/358/problem/B 先按照题意说的构造一个字符串s,然后与对比的字符串T比较,看看在字符串T中顺序查找有没有字符串S的所有字符,有输 ...

  8. CF 366E - Dima and Magic Guitar 最远曼哈顿距离

    题目:http://codeforces.com/problemset/problem/366/E 事实上就是找 n * m 矩阵中数字 x 和 数字 y 的最远距离. 方法參照武森的论文<浅谈 ...

  9. CF 272E Dima and Horses 染色,dfs 难度:2

    http://codeforces.com/problemset/problem/272/E 把仇恨关系想象为边, 因为度只能为0,1,2,3,所以有以下几种 0,1 直接放即可 2: 有(1,1), ...

随机推荐

  1. Smarty 使用继承方式实现配置

    . 常用配置选项 在使用Smarty模板引擎之前,我们必须先学习如何配置Smarty的选项.而在Smarty的常见选项中,我们首先必须了解4个最基本的目录选项. 模板目录(template):本目录用 ...

  2. 手机低端市场,联发科 vs 高通

    联发科(MTK) 是山寨机的源头,我过去曾经鄙视他,现在来了180度转弯. 其实联发科是台湾的上市公司,手机如此复杂的东西,当年 联发科能把基础的手机做出来,而后小山寨厂改改外形,配件就能出若干款手机 ...

  3. hdu&&poj搜索题题号

    搜索 hdu1067 哈希 hdu1401 双向搜索 hdu1430 哈希 hdu1667 跌搜+启发式函数 hdu1685 启发式搜索 hdu1813 启发式搜索 hdu1885 状态压缩搜索 hd ...

  4. linux image writes boot log to console

  5. MyEclipse 10.x中拓展自动提示功能

    原文转自:MyEclipse 10.7中拓展自动提示功能 在myeclipse 9以前的版本中,我们如果要为html编辑器添加自动的代码提示可以这样操作: 1.windows-->prefere ...

  6. (转)关于Android的nodpi,xhdpi,hdpi,mdpi,ldpi

    首先是几个基本概念:1.屏幕尺寸Screen size即显示屏幕的实际大小,按照屏幕的对角线进行测量.为简单起见,Android把所有的屏幕大小分为四种尺寸:小,普通,大,超大(分别对应:small, ...

  7. Javascript:DOM表格操作

    需求说明: /* *需求说明: *获取元素:tBodies,tHead,tFoot,rows,cells *表格的创建 *数据添加 *隔行变色 *删除操作,剩余表格重新计算,实现隔行变色 */ HTM ...

  8. DevExpress之进度条

    progressBarControl和marqueeProgressBarControl 一.progressBarControl progressBarControl是一个进度条控件 几个重要参数 ...

  9. Quartz中时间表达式的设置-----corn表达式

    Quartz中时间表达式的设置-----corn表达式 时间格式: <!-- s m h d m w(?) y(?) -->,   分别相应: 秒>分>小时>日>月 ...

  10. 命令行运行android模拟器

    创建模拟器 android create avd --name avd_4.1 --target "android-16" --abi armeabi-v7a Android 4. ...