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. Codeforces Round #236 (Div. 2)E. Strictly Positive Matrix(402E)

    E. Strictly Positive Matrix   You have matrix a of size n × n. Let's number the rows of the matrix f ...

  2. USACO6.4-Wisconsin Squares:搜索

    Wisconsin Squares It's spring in Wisconsin and time to move the yearling calves to the yearling past ...

  3. MySQL函数简介

    //将时间戳长整形数值转换为yyyy-MM-dd HH:mm:ss格式SELECT FROM_UNIXTIME(CREATE_TIME, '%Y-%m-%d %H:%i:%S') FROM TBLS ...

  4. RequireJS进阶(二)

    这一篇来认识下打包工具的paths参数,在入门一中就介绍了require.config方法的paths参数.用来配置jquery模块的文件名(jQuery作为AMD模块时id为“jquery”,但文件 ...

  5. android2.3 View视图框架源码分析之一:android是如何创建一个view的?

    View是所有控件的一个基类,无论是布局(Layout),还是控件(Widget)都是继承自View类.只不过layout是一个特殊的view,它里面创建一个view的数组可以包含其他的view而已. ...

  6. windows下php+apache+mysql环境搭建

    在Windows 7下进行PHP环境搭建,首先需要下载PHP代码包和Apache与Mysql的安装软件包. PHP版本:php-5.3.2-Win32-VC6-x86,VC9是专门为IIS定制的,VC ...

  7. cocos2d-x 2.x 图层特效Effect(转)

    CCSprite* sp = CCSprite::create("Default.png"); sp->setPosition(ccp(, )); addChild(sp); ...

  8. Python之基础(一)

    数学计算 要利用相关的数学计算函数,首先需要把数学模块包含进来: >>>import math 进行计算: >>> math.pi 3.14159265358979 ...

  9. zabbix监控应用连接数

    zabbix使用用户自定义键值来监控应用系统连接数: 1.修改配置文件zabbix_agentd.conf 格式: UserParameter=<key>,<shell comman ...

  10. SQL转换函数to_char/to_date/to_number

    日期型->字符型转换函数to_char(d [,fmt]) 函数to_char(d [,fmt])用于将日期型数值转换为字符串(varchar2类型),其中参数d用于指定日期值,fmt用于指定要 ...