单调栈

题意看了半天。。。

     #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long const int maxn=2e5+;
const int inf=1e9; int sum1,tot1;
int f[maxn],g; int main()
{
int n,a,b,i,j,v;
scanf("%d",&n);
for (i=;i<=n;i++)
{
scanf("%d",&a);
if (a== || a==)
scanf("%d",&b); if (a==)
tot1=;
else if (a==)
tot1++;
else if (a==)
sum1+=tot1,tot1=; if (a==)
g=;
else if (a==)
{
v=b;
while (g> && f[g]<v)
g--,sum1++;
}
else if (a==)
{
if (b<v)
sum1++;
else
f[++g]=b;
}
}
printf("%d",sum1);
return ;
}

Educational Codeforces Round 27 D. Driving Test的更多相关文章

  1. Educational Codeforces Round 27 补题

    题目链接:http://codeforces.com/contest/845 A. Chess Tourney 水题,排序之后判断第n个元素和n+1个元素是不是想等就可以了. #include < ...

  2. Educational Codeforces Round 27 A B C

    A. Chess Tourney   Berland annual chess tournament is coming! Organizers have gathered 2·n chess pla ...

  3. Educational Codeforces Round 27

    期末后恢复性训练,结果完美爆炸... A,题意:2n个人,分成两队,要求无论怎么分配,第一队打赢第二队 #include<bits/stdc++.h> #define fi first # ...

  4. Educational Codeforces Round 27 F. Guards In The Storehouse

    F. Guards In The Storehouse time limit per test 1.5 seconds memory limit per test 512 megabytes inpu ...

  5. Educational Codeforces Round 117 (Rated for Div. 2)

    Educational Codeforces Round 117 (Rated for Div. 2) A. Distance https://codeforces.com/contest/1612/ ...

  6. [Educational Codeforces Round 16]E. Generate a String

    [Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...

  7. [Educational Codeforces Round 16]D. Two Arithmetic Progressions

    [Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic pr ...

  8. [Educational Codeforces Round 16]C. Magic Odd Square

    [Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different number ...

  9. [Educational Codeforces Round 16]B. Optimal Point on a Line

    [Educational Codeforces Round 16]B. Optimal Point on a Line 试题描述 You are given n points on a line wi ...

随机推荐

  1. SaaS,PaaS,IaaS都是什么鬼?

    IaaS Infrastructure as a Service,基础设施即服务. 假如你现在要做一个网站,你肯定要有一台服务器或者虚拟机,要么自己搭建,要么买服务器运营商的.说白了,IaaS就是解决 ...

  2. 8-MySQL-Ubuntu-数据表中数据的增加(一)

    增(insert) (1)全部字段插入数据:按表中字段顺序增加数据 注:(1)主键字段可以使用0/null/default来占位.(2)gender字段中数据类型是枚举,可以使用索引数字1,2,3,4 ...

  3. Straight Master (贪心)

    题目如下:A straight is a poker hand containing five cards of sequential rank, not necessarily to be the ...

  4. Pandaria(Kruskal重构树+线段树合并)

    题意 是 有n个花园 一个花园内所有的花的颜色都是一样的 有很多种不同的颜色  花园到花园之间有路,走不同的路有不同的代价   如果选一个点作为起点 只走小于等于w的路  可以经过的这些花园里  那种 ...

  5. The chance for love doesn't come around every day.

    The chance for love doesn't come around every day.爱的机会不是每天都有的.

  6. Delphi之TPersistent类 -----ASSIGN

    Delphi之TPersistent类 TPersistent类 TPersistent类是由TObject直接派生的.凡是由TPersistent派生的对象都能够进行流操作.因为所有的组件都是由TP ...

  7. Delphi StringGrid常用属性和常用操作

    StringGrid组件用于建立显示字符串的网格,与电子表格相似.它可使表格中的字符串和相关对象操作简单化.StringGrid组件提供了许多可控制网格外观念的属性,以及利用表格的结构响应用户操作的事 ...

  8. HTML中的相对路径与绝对路径

    路径 实际工作中,通常新建一个文件夹专门用于存放图像文件,这时再插入图像,就需要采用“路径”的方式来指定图像文件的位置. 路径可以分为: 相对路径和绝对路径 相对路径 图像文件和HTML文件位于同一文 ...

  9. 绘制窗体渐变背景的函数[delphi]

    绘制窗体渐变背景的函数,三个参数分别代表起始颜色,终止颜色,绘制方向procedure TForm1.Draw(StartColor:TColor;EndColor:TColor;Direction: ...

  10. csp-s模拟测试99

    csp-s模拟测试99 九九归一直接爆炸. $T1$一眼板子. $T2$一眼语文题(语文的唯一一次$120+$是给模拟出来的可知我的语文能力). $T3$一眼普及题. ?? Hours Later 板 ...