单调栈

题意看了半天。。。

  1. #include <cstdio>
  2. #include <cstdlib>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <string>
  6. #include <algorithm>
  7. #include <iostream>
  8. using namespace std;
  9. #define ll long long
  10.  
  11. const int maxn=2e5+;
  12. const int inf=1e9;
  13.  
  14. int sum1,tot1;
  15. int f[maxn],g;
  16.  
  17. int main()
  18. {
  19. int n,a,b,i,j,v;
  20. scanf("%d",&n);
  21. for (i=;i<=n;i++)
  22. {
  23. scanf("%d",&a);
  24. if (a== || a==)
  25. scanf("%d",&b);
  26.  
  27. if (a==)
  28. tot1=;
  29. else if (a==)
  30. tot1++;
  31. else if (a==)
  32. sum1+=tot1,tot1=;
  33.  
  34. if (a==)
  35. g=;
  36. else if (a==)
  37. {
  38. v=b;
  39. while (g> && f[g]<v)
  40. g--,sum1++;
  41. }
  42. else if (a==)
  43. {
  44. if (b<v)
  45. sum1++;
  46. else
  47. f[++g]=b;
  48. }
  49. }
  50. printf("%d",sum1);
  51. return ;
  52. }

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. DFS问题举例:N个整数选k个使其和为x

    N个整数选k个使其和为x,若有多个方案,选择元素平方和最大的一个 #include<cstdio> #include<cmath> #include<cstring> ...

  2. <Git>git学习

    1.安装 分布式版本控制:工作电脑保存完整的代码,中央服务器挂了也可以使用 集中式版本控制:中央服务器挂了就凉凉 sudo apt-get install git git安装 检测安装成功 git 2 ...

  3. Cyclical Quest CodeForces - 235C 后缀自动机

    题意: 给出一个字符串,给出一些子串,问每个子串分别在母串中圆环匹配的次数, 圆环匹配的意思是将该子串拆成两段再首位交换相接的串和母串匹配,比 如aaab变成baaa,abaa,aaba再进行匹配. ...

  4. JQuery日记6.7 Javascript异步模型(二)

    异步模型看起来非常美,但事实上它也是有天生缺陷的.看以下代码 try { setTimeout( function(){ throw new Error( '你抓不到我的!' ); }, 100); ...

  5. nuxt 利用lru-cache 做服务器数据请求缓存

    // 运行与服务端的js // node.js lru-cache import LRU from 'lru-cache' const lruCache = LRU({ // 缓存队列长度 max: ...

  6. python接口自动化(put请求)

    python接口自动化(put请求) 一.put请求的作用:更新资源 二.应用 导包:import requests 调用requests.put()方法 参数有URL.data.headers,方法 ...

  7. python--序列化:json、pickle、shelva

    序列化 数据类型--->str 一个模块就是一个包含了python定义和声明的文件,文件名就是模块名字加上.py的后缀. 反序列化 str--->数据类型 序列化三大方法:json *** ...

  8. 2019_7_31python

    练习  输入三条边长如果能构成三角形就计算周长和面积 import math a,b,c = input().split(',') a = float(a) b = float(b) c = floa ...

  9. Berry 指令设计

    Berry 脚本源代码需要被编译为字节码指令流才能被 Berry 虚拟机执行.本文将详细地讲解 Berry 字节码指令(下面简称指令)的设计和实现.为了达到这个目的,本文由 3 部分构成:第 1 小节 ...

  10. eclipse打包jar及第三方jar包一起导出(生成SDK)

    一.前言: 因公司需求,需要将某个工具类供外部使用,所以需要生成jar文件.但是jar内还包含了第三方的jar,普通的打包方式无法将lib下的第三方jar包提取. 这将会导致工具jar无法运行,或Ex ...