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), ...
随机推荐
- 【HDOJ】3518 Boring Counting
后缀数组2倍增可解. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXN 10 ...
- 2015第29周六Spring
搜了一下Spring相关的经典书籍: <Spring实战(第3版)>从核心的Spring.Spring应用程序的核心组件.Spring集成3个方面,由浅入深.由易到难地对Spring展开了 ...
- C++中使用stringstream进行类型转换操作
stringstream包括istringstream和ostringstream,提供读写string的功能,使用时需包含stream文件.4个操作:1. stringstream strm; 创建 ...
- Java 反射机制详解
动态语言 动态语言,是指程序在运行时可以改变其结构:新的函数可以被引进,已有的函数可以被删除等在结构上的变化.比如众所周知的ECMAScript(JavaScript)便是一个动态语言.除此之外如Ru ...
- Java语言实现简单FTP软件------>上传下载队列窗口的实现(七)
1.首先看一下队列窗口的界面 2.看一下上传队列窗口的界面 3.看一下下载队列窗口的界面 4.队列窗口的实现 package com.oyp.ftp.panel.queue; import stati ...
- iBatis查询结果部分为null的解决办法
今天第一天接触iBatis,没有系统学习过,遇到了一个简单却闹心的错误:用iBatis查询数据库中某个表的多列结果作为一个对象返回时,会出现对象的部分属性为null值得错误.例如,查询用户表中的用户I ...
- 博客换了,比较少用这个博客(http://loid.cf)
新博客地址: http://loid.cf/
- Java正則表達式语法
Java正則表達式语法 字符 说明 \ 将下一字符标记为特殊字符.文本.反向引用或八进制转义符.比如,"n"匹配字符"n"."\n"匹配换行 ...
- mac os使用lsusb命令和连接未知的Android设备
今天在mac上连接一个android设备发现连不上,adb devices看不到设备.于是想用lsusb命令看下,结果发现Mac居然没有这个命令,于是网上搜了下.发现了以下的命令system_prof ...
- Welcome to Apache™ Hadoop®!
What Is Apache Hadoop? Getting Started Download Hadoop Who Uses Hadoop? News 15 October, 2013: relea ...