51Nod 1279 扔盘子 (思维+模拟)
题意:
有口井,往里扔盘子,最多扔多少个

n<=5e5, 1s
思路:
如果比较高的地方井口比较小,那么下面的再大也没有用,只需要维护一个单调减的数组然后O(n+m)模拟即可
代码:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<functional> #define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x)) using namespace std; typedef double db;
typedef long double ldb;
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL; const db eps = 1e-;
const int mod = 1e9+;
const int maxn = 2e6+;
const int maxm = 2e6+;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0); int a[maxn];
int b[maxn];
int n,m;
int main(){ int tmp = inf;
scanf("%d %d", &n,&m);
for(int i = ; i <= n; i++){
scanf("%d", &a[i]);
tmp = min(tmp, a[i]);
a[i] = min(tmp, a[i]);
}
int ans = ;
int p = n;
for(int i = ; i <= m; i++){
int x;
scanf("%d", &x);
while(p>=&&a[p]<x){
p--;
}
if(p){p--;ans++;} }
printf("%d",ans);
return ; }
51Nod 1279 扔盘子 (思维+模拟)的更多相关文章
- 51Nod 1279:扔盘子(二分||单调栈)
1279 扔盘子 1.0 秒 131,072.0 KB 5 分 1级题 有一口井,井的高度为N,每隔1个单位它的宽度有变化.现在从井口往下面扔圆盘,如果圆盘的宽度大于井在某个高度的宽度,则圆盘被卡住( ...
- 51Nod-1279 扔盘子
51Nod: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1279 1279 扔盘子 题目来源: Codility 基 ...
- 51nod 1279 单调栈
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1279 1279 扔盘子 题目来源: Codility 基准时间限制:1 ...
- 51nod 扔盘子
题目传送门 这道题一开始写了n方的算法 果不其然 它T了 所以就想想o(n)的算法 写不出来 就像sbzhq学习了一下 这道题啊 要维护一下从深度1到n每一段的最小值以及他的位置 然后就暴力搞一搞就o ...
- CF--思维练习--CodeForces - 216C - Hiring Staff (思维+模拟)
ACM思维题训练集合 A new Berland businessman Vitaly is going to open a household appliances' store. All he's ...
- 思维+模拟--POJ 1013 Counterfeit Dollar
Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are true silver d ...
- C. Okabe and Boxes 思维 模拟 or 线段树
C. Okabe and Boxes 这个题目是一个有点思维的模拟,当时没有想到, 思维就是这个栈的排序这里,因为每次直接排序肯定会t的,所以不可以这么写,那怎么表示排序呢? 就是直接把栈清空,如果栈 ...
- Codeforces Round #706 (Div. 2)B. Max and Mex __ 思维, 模拟
传送门 https://codeforces.com/contest/1496/problem/B 题目 Example input 5 4 1 0 1 3 4 3 1 0 1 4 3 0 0 1 4 ...
- Educational Codeforces Round 63 (Rated for Div. 2) B. Game with Telephone Numbers 博弈思维+模拟+贪心思维
题意:博弈题面 给出一个数字序列 (>=11) 有两个人任意删除数字 直到 数字只剩下11位 如果删除后的数字串开头是8那么就是第一个赢 否则就是第二个人赢 第一个人先手 数字序列一定是奇 ...
随机推荐
- placeHolder和defaultValue的区别
placeHolder和defaultValue的区别 (1)placeHolder用于提示用户,它不与后端进行交互. (2)defaultValue则是与后端交互时的默认值. 举例说明:在Selec ...
- 线程池:ThreadPoolExecutor的使用
ThreadPoolExecutor配置 一.ThreadPoolExcutor为一些Executor提供了基本的实现,这些Executor是由Executors中的工厂 newCahceThread ...
- java小项目之:扫雷,这游戏没有你想的那么简单!
扫雷 我之前分享的小项目和小游戏,电影购票.坦克大战.捕鱼达人.贪吃蛇等,虽然已经是耳熟能详人尽皆知的项目和游戏,但是保不齐真的有人没接触过. 今天分享的这个项目,我不相信没人接触过(仅限80后-00 ...
- ASP.NET Core Web程序托管到Windows 服务
前言 在 .NET Core 3.1和WorkerServices构建Windows服务 我们也看到了,如何将workerservices构建成服务,那么本篇文章我们再来看看如何将web应用程序托管到 ...
- 2013 ACM/ICPC Asia Regional Online —— Warmup2 ABEGKL
HDU4716 A. A Computer Graphics Problem A题目描述 题意:输出手机剩余电量,保证给出的数是10的倍数. 题解:水题,按题意输出即可. 代码: #include & ...
- 你的应用安全吗? ——用Xray和Synk保驾护航
一.背景 在当下软件应用的开发过程当中,自研的内部代码所占的比例逐步地减少,开源的框架和共用库已经得到了广泛的引用.如下图所示,在一个Kubernetes部署的应用当中,我们自己开发代码所占的比例可能 ...
- 简单的c语言程序
我猜大部分人第一门掌握的语言是c语言吧(我第一门学的是python). 在接下来的文章里我会逐步的介绍有关自己对c语言的理解,希望对一些小伙伴有帮助,有哪里有错误希望大佬指出. 首先这是第一个c语言程 ...
- Eureka 主动下线服务
原因: 测试环境由于机器换ip,神奇的出现了更新之前,之后的IP同时在Eureka上注册了. 方法一:直接停掉服务 默认情况下,如果Eureka Server在90秒没有收到Eureka客户的续约,它 ...
- window 10 安装Oracle odac 64位
下载地址:https://www.oracle.com/cn/database/technologies/windows/downloads.html 可以下载XCopy版,也可以继续往下看下载安装文 ...
- KMO检验和Bartlett球形检验
KMO检验和Bartlett球形检验因子分析前,首先进行KMO检验和巴特利球体检验,KMO检验系数>0.5,(巴特利特球体检验的x2统计值的显著性概率)P值<0.05时,问卷才有结构效度, ...