cf C. Dima and Containers
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的更多相关文章
- cf D. Dima and Trap Graph
http://codeforces.com/contest/366/problem/D 遍历下界,然后用二分求上界,然后用dfs去判断是否可以. #include <cstdio> #in ...
- CF 366E Dima and Magic Guitar(最远哈密顿距离)
题目链接:http://codeforces.com/problemset/problem/366/E 题意:给出一个n*m的数字矩阵A,每个矩阵元素的范围[1,K].给出一个长度为s的数字串B,B的 ...
- 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 ...
- cf C. Dima and Salad
http://codeforces.com/contest/366/problem/C 转化为背包问题,可以将a[i]-b[i]*k看成重量,a[i]为价值: 因为a[i]-b[i]*k可以为负数,所 ...
- 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 ...
- cf D. Dima and Hares
http://codeforces.com/contest/358/problem/D 题意:ai代表相邻的两个野兔都没有吃食物情况下的快乐系数,bi代表的是在相邻的两个野兔中有一个吃到食物的快乐系数 ...
- cf B. Dima and Text Messages
http://codeforces.com/contest/358/problem/B 先按照题意说的构造一个字符串s,然后与对比的字符串T比较,看看在字符串T中顺序查找有没有字符串S的所有字符,有输 ...
- CF 366E - Dima and Magic Guitar 最远曼哈顿距离
题目:http://codeforces.com/problemset/problem/366/E 事实上就是找 n * m 矩阵中数字 x 和 数字 y 的最远距离. 方法參照武森的论文<浅谈 ...
- CF 272E Dima and Horses 染色,dfs 难度:2
http://codeforces.com/problemset/problem/272/E 把仇恨关系想象为边, 因为度只能为0,1,2,3,所以有以下几种 0,1 直接放即可 2: 有(1,1), ...
随机推荐
- 在QLabel上点击获得的效果
一般说只在button中点击获得事件,作出相应的反应.而往往需要在QLabel上作出点击和触碰的效果. 我用qlabel做出了一个效果,当鼠标碰到label区域,label底下出现一条线,离开后线条消 ...
- 一道面试题与Java位操作 和 BitSet 库的使用
前一段时间在网上看到这样一道面试题: 有个老的手机短信程序,由于当时的手机CPU,内存都很烂.所以这个短信程序只能记住256条短信,多了就删了. 每个短信有个唯一的ID,在0到255之间.当然用户可能 ...
- 2015第24周五Spring的AOP
AOP(面向方面编程:Aspect Oriented Programing)和IoC一样是Spring容器的内核,声明式事务的功能在此基础上开花结果.但AOP的应用场合是受限的,它一般只适合于那些具有 ...
- LeeCode-String to Integer (atoi)
Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. ...
- java与数据结构(8)---java实现链队列
链队列 实际上就是单链表,只是规定了删除在队头进行,添加在队尾进行. 链队列代码结构 package list.queue; public interface Queuable<T>; p ...
- openstack neutron debugs lists
- .Net词汇表中常见缩略语汇总
.Net中存在大量的专业词汇(详细列表,请参考:Visual Studio 和 .NET Framework 词汇表),其中很多词汇常常采用缩略语的形式被大量使用. 在阅读.Net书籍或网络资料时,便 ...
- Python进阶(面向对象编程基础)(二)
1.初始化实例属性 #!/usr/bin/env python # -*- coding:utf-8 -*- __author__ = 'ziv·chan' #定义Person类的__init__方法 ...
- PLSQL developer 连接不上64位Oracle 的解决方法
Windows 64位下装Oracle 11g 64位,PLSQL Developer使用出现以下问题: 1.Database下拉框为空:2.强制输入用户名.密码及Database,登录弹出: 引用 ...
- Linux内核ROP学习
0x00 前言 1.SMEP(Supervisor Mode Execution Protection):一种减缓内核利用的cpu策略,禁止内核态到用户态内存页的代码执行(32位的addresses ...