Educational Codeforces Round 27 D. Driving Test
单调栈
题意看了半天。。。
- #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的更多相关文章
- Educational Codeforces Round 27 补题
题目链接:http://codeforces.com/contest/845 A. Chess Tourney 水题,排序之后判断第n个元素和n+1个元素是不是想等就可以了. #include < ...
- Educational Codeforces Round 27 A B C
A. Chess Tourney Berland annual chess tournament is coming! Organizers have gathered 2·n chess pla ...
- Educational Codeforces Round 27
期末后恢复性训练,结果完美爆炸... A,题意:2n个人,分成两队,要求无论怎么分配,第一队打赢第二队 #include<bits/stdc++.h> #define fi first # ...
- 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 ...
- Educational Codeforces Round 117 (Rated for Div. 2)
Educational Codeforces Round 117 (Rated for Div. 2) A. Distance https://codeforces.com/contest/1612/ ...
- [Educational Codeforces Round 16]E. Generate a String
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...
- [Educational Codeforces Round 16]D. Two Arithmetic Progressions
[Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic pr ...
- [Educational Codeforces Round 16]C. Magic Odd Square
[Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different number ...
- [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 ...
随机推荐
- DFS问题举例:N个整数选k个使其和为x
N个整数选k个使其和为x,若有多个方案,选择元素平方和最大的一个 #include<cstdio> #include<cmath> #include<cstring> ...
- <Git>git学习
1.安装 分布式版本控制:工作电脑保存完整的代码,中央服务器挂了也可以使用 集中式版本控制:中央服务器挂了就凉凉 sudo apt-get install git git安装 检测安装成功 git 2 ...
- Cyclical Quest CodeForces - 235C 后缀自动机
题意: 给出一个字符串,给出一些子串,问每个子串分别在母串中圆环匹配的次数, 圆环匹配的意思是将该子串拆成两段再首位交换相接的串和母串匹配,比 如aaab变成baaa,abaa,aaba再进行匹配. ...
- JQuery日记6.7 Javascript异步模型(二)
异步模型看起来非常美,但事实上它也是有天生缺陷的.看以下代码 try { setTimeout( function(){ throw new Error( '你抓不到我的!' ); }, 100); ...
- nuxt 利用lru-cache 做服务器数据请求缓存
// 运行与服务端的js // node.js lru-cache import LRU from 'lru-cache' const lruCache = LRU({ // 缓存队列长度 max: ...
- python接口自动化(put请求)
python接口自动化(put请求) 一.put请求的作用:更新资源 二.应用 导包:import requests 调用requests.put()方法 参数有URL.data.headers,方法 ...
- python--序列化:json、pickle、shelva
序列化 数据类型--->str 一个模块就是一个包含了python定义和声明的文件,文件名就是模块名字加上.py的后缀. 反序列化 str--->数据类型 序列化三大方法:json *** ...
- 2019_7_31python
练习 输入三条边长如果能构成三角形就计算周长和面积 import math a,b,c = input().split(',') a = float(a) b = float(b) c = floa ...
- Berry 指令设计
Berry 脚本源代码需要被编译为字节码指令流才能被 Berry 虚拟机执行.本文将详细地讲解 Berry 字节码指令(下面简称指令)的设计和实现.为了达到这个目的,本文由 3 部分构成:第 1 小节 ...
- eclipse打包jar及第三方jar包一起导出(生成SDK)
一.前言: 因公司需求,需要将某个工具类供外部使用,所以需要生成jar文件.但是jar内还包含了第三方的jar,普通的打包方式无法将lib下的第三方jar包提取. 这将会导致工具jar无法运行,或Ex ...