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 ...
随机推荐
- C-Ubuntu中MySQL出现ERROR1698(28000):Access denied for user root@localhost错误解决方法
卸载原先的MySQL,重新安装过程中没有提示设置密码, 当键入命令:mysql -uroot -p; 不知密码是什么,输入主机的密码以及不输入密码,回车后都出现标题错误. 寻找多篇相关博文,验证如下博 ...
- git branch 分支和分支合并
一般一个项目有一个默认的分支 master 主分支,然后可以有许多个分支,在别的分支上的操作不会影响到主分支.使用git branch查看当前多多少分支以及当前处于哪个分支上:执行git branch ...
- pytest--fixture---自动应用
import pytest@pytest.fixture(autouse=True)-----加上auto=True,每个方法执行前都会自动登陆def login_r(open_browser): p ...
- C语言结构体和函数
#include <stdio.h> struct Person { char *name; }; void change1(struct Person p); void change2( ...
- Ansible角色
Ansible角色介绍 官方地址: https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html 角色目录 ...
- Interview - 面试题汇总目录
参考 java 入门面试题 https://blog.csdn.net/meism5/article/details/89021536 一.Java 基础 1.JDK 和 JRE 有什么区别? 2.= ...
- 关于第一次web前端面试的记录
最近参加了一场面试,感觉自己题目都懂,但是说起来就是有点说不明白,所以写个博客整理以下吧.答案不少不是面试时回答的答案,只是整理一下可行答案 1. 如图1,使B相对于A垂直居中 图1 <styl ...
- Android NDK 环境变量配置
NDK_ROOT = C:\__S_D_K__\AndroidNDK\android-ndk-r20 在path 中加入 %NDK_ROOT% 我的路径在C盘 //个别的程序可能需要 NDK_ROO ...
- luoguP1415 拆分数列 [dp]
题目描述 给出一列数字,需要你添加任意多个逗号将其拆成若干个严格递增的数.如果有多组解,则输出使得最后一个数最小的同时,字典序最大的解(即先要满足最后一个数最小:如果有多组解,则使得第一个数尽量大:如 ...
- kafka和flume进行整合的日志采集的confi文件编写
配置flume.conf 为我们的source channel sink起名 a1.sources = r1 a1.channels = c1 a1.sinks = k1 指定我们的source收集到 ...