单调栈

题意看了半天。。。

     #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. sqlserver 如何瞬间执行上万条数据

    核心的内容是:使用自定义表类型 第一步:创建存储过程P_T1DeclareInfo_Upload_new 参数: T1DeclareInfo_UploadPNSN_Param  类型 T1Declar ...

  2. linux下alsa架构音频驱动播放wav格式文件

    #include<stdio.h> #include<stdlib.h> #include <string.h> #include <alsa/asoundl ...

  3. 3.Struts2中Action类的三种写法

    一.普通的POJO类(没有继承没有实现)-基本不使用 public class DemoAction1 { public String execute(){ System.out.println(&q ...

  4. 45. Collection

    因为Collection是接口我们不能直接实例化,所以我们下面的例子都是采用多态实例化实现类ArrayList类 1. Collection中常用方法 添加:    add()  添加一个元素到集合中 ...

  5. scala中函数简单使用记录

    object funcHighLevel { def main(args: Array[String]): Unit = { // 创建一个匿名函数 val sayFunc = (name: Stri ...

  6. spark在collect收集数据的时候出现outOfMemoryError:java heap space

    spark的collect是action算子,所有最后会以数组的形式返回给driver端,当数据太大的时候就会出现堆内存溢出.OutofMemoryError:java heap space. 在sp ...

  7. [Nowcoder] 数数字

    题意:...咕咕懒得写了. 思路: 裸的记搜... #include <bits/stdc++.h> using namespace std; #define ll long long m ...

  8. hdu多校第一场1004(hdu6581)Vacation 签到

    题意:有n+1辆车,每辆车都有一定的长度,速度和距离终点的距离,第1-n辆车在前面依次排列,第0辆车在最后面.不允许超车,一旦后车追上前车,后车就减速,求第0辆车最快什么时候能到达终点? 思路:对于每 ...

  9. Spring-Security (学习记录七)--实现FilterInvocationSecurityMetadataSource的类将无法切入声明式事物

    目录 1 查看继承关系 2 说明 3 查看源码: 实现了FilterInvocationSecurityMetadataSource 的类将无法切入声明式事物. 原因: 1 查看继承关系 先查看Fil ...

  10. 用注册表创建无法删除的IE快捷方式

    代码如下: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE/SOFTWARE/Classes/CLSID/{98745625-1234 ...