单调栈

题意看了半天。。。

     #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. Pandas异常值处理

    import pandas as pd #生成异常数据 df=pd.DataFrame({'col1':[1,120,3,5,2,12,13], 'col2':[12,17,31,53,22,32,4 ...

  2. Spring IOC源码分析(二):Bean工厂体系结构设计

    一. 概述 Spring容器通常指的是ApplicationContext的体系结构设计,即整个Spring框架的IOC功能,是通过ApplicationContext接口实现类来提供给应用程序使用的 ...

  3. Linux的各个发行版本(二)

    CentOS CentOS是世界上使用的最好的Linux服务器发行版之一,占了全世界Linux服务器的30%. 它是Red Hat 的衍生产品,提供了稳定的服务器环境. 特点: 支持的X86-64架构 ...

  4. jsonp的实现原理

    jsonp的实现原理 由于浏览器的安全性(同源策略)限制,不允许AJAX访问协议不同或域名不同或端口号不同的数据接口: 可以通过动态创建script标签的方式,把script标签的src属性指向数据接 ...

  5. UTF-8 - ASCII 兼容的多字节 Unicode 编码

    描述 The Unicode 字符集使用的是 16 位(双字节)码.最普遍的 Unicode 编码方法( UCS-2) 由一个 16 位双字序列组成.这样的字符串中包括了的一些如‘\0’或‘/’这样的 ...

  6. Java调用Linux下的shell命令并将结果以流的形式返回

    import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader; public cl ...

  7. 影响RAKsmart服务器稳定性的相关因素

    RAKsmart美国服务器近年来凭借着成熟的技术和性价比吸引着广大站长,那RAKsmart服务器稳定性怎么样呢?有什么影响因素呢?下面来了解一下吧. 因素一:服务器配置 服务器能正常运营是建立在服务器 ...

  8. 【PKUWC2018】猎人杀

    题目描述 题目分析 设\(W=\sum\limits_{i=1}^nw_i\),\(A=\sum\limits_{i=1}^nw_i[i\ is\ alive]\),\(P_i\)为下一个打中\(i\ ...

  9. .net core 读取appsetting.json

    1.在appsetting.json 文件中添加自定义配置 { "Logging": { "LogLevel": { "Default": ...

  10. JUC 一 ConcurrentHashMap

    java.util.concurrent ConcurrentHashMap是一个支持并发检索和并发更新的线程安全的HashMap(但不允许空key或value). JDK8以CAS+synchron ...