set使用实例1+lower_bound(val):

 #include<stdio.h>
#include<set>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<map>
using namespace std;
int main()
{
int n;
while(~scanf("%d",&n))
{
map<int ,int>lson,rson;
set<int >s;
set<int >::iterator pos;
for(int i=;i<n;i++)
{
int x;
scanf("%d",&x);
if(i==)
{
s.insert(x);
continue;
}
pos=s.lower_bound(x);
if(pos!=s.end()&&lson[*pos]==)
{
lson[*pos]=x;
}
else
{
pos--;
rson[*pos]=x;
}
printf("%d ",*pos);
s.insert(x);
}
printf("\n");
}
}

set使用实例1+lower_bound(val)(个人模版)的更多相关文章

  1. python中的实例方法、静态方法、类方法、类变量和实例变量

    class MyTest: myname = 'peter' # add a instance attribute    def __init__(self, name):        self.n ...

  2. C++学习笔记36 (模板的细节明确template specialization)和显式实例(template instantiation)

    C++有时模板很可能无法处理某些类型的. 例如: #include <iostream> using namespace std; class man{ private: string n ...

  3. CodeSmith的基础模版类(CodeSmith help中的内容)

    基础模版类类型描述: Batch      OutputFileCodeTemplate  模版通过继承此类能够在生成过程中把他们的输出保存到文件中 ScriptError    在脚本执行中出现一个 ...

  4. 鬼知道是啥系列之——STL(lower_bound(),upper_bound() )

    引子,不明觉厉:   百度,渐入佳境: 头铁,入门到放弃: lower_bound(): 头文件:  #include<algorithm>函数功能:  函数lower_bound()在f ...

  5. Kotlin基本语法笔记3之定义类、继承及创建实例

    定义类 class MyObject private constructor(name: String, age: Int) { private var name: String private va ...

  6. C++ lower_bound 与 upper_bound 函数

    头文件: #include  <algorithm> 二分查找的函数有 3 个: 参考:C++ lower_bound 和upper_bound lower_bound(起始地址,结束地址 ...

  7. 设计模式-Java版-全-附代码-超生动实例

    阅读推荐:设计模式-简单篇 项目地址:https://gitee.com/zwtgit/gof23 学习网站推荐: https://refactoringguru.cn/design-patterns ...

  8. JS魔法堂:深究JS异步编程模型

    前言  上周5在公司作了关于JS异步编程模型的技术分享,可能是内容太干的缘故吧,最后从大家的表情看出"这条粉肠到底在说啥?"的结果:(下面是PPT的讲义,具体的PPT和示例代码在h ...

  9. 利用Java动态生成 PDF 文档

    利用Java动态生成 PDF 文档,则需要开源的API.首先我们先想象需求,在企业应用中,客户会提出一些复杂的需求,比如会针对具体的业务,构建比较典型的具备文档性质的内容,一般会导出PDF进行存档.那 ...

随机推荐

  1. 使用canvas实现绚丽的时钟特效

    源码 https://github.com/2016Messi/Gorgeous-clock 效果展示 https://2016messi.github.io/Gorgeous-clock/ 如果各位 ...

  2. 数值函数ROUND(四舍五入),TRUNC(不四舍五入),MOD

  3. Linux简介,虚拟机安装,网络设置,桌面和vim安装

    Linux简介: linux代表系统内核.Linux系统指基于Linux内核的操作系统,由内核和程序结合组成.比较流行的发行版本由RedHat Linux.Fedora.Centos.Debian.U ...

  4. iOS OC利用imageview属性切出类似圆柱图形

    效果一: 效果二: 上边的图形我也数不出来名字,,暂称圆柱正切图形吧,看到这样的需求似不似在想各种插件,各种切图方法了呢... UIImageView的属性可以轻松搞定 UIViewContentMo ...

  5. NSQ之粗读浅谈

    回顾: 以前一直是C++开发(客户端),最近听同事讲go语言不错,随后便决定先从go语法开始投向go的怀抱.由于历史原因学习go语法时,用了半天的时间看完了菜鸟教程上相关资料,后来又看了易百教程上的一 ...

  6. 创建一个可用的简单的SpringMVC项目,图文并茂

    转载麻烦注明下来源:http://www.cnblogs.com/silentdoer/articles/7134332.html,谢谢. 最近在自学SpringMVC,百度了很多资料都是比较老的,而 ...

  7. Android Activity生命周期详细解析

    概况 讲Android Activity那怎么都绕不过这张图,这篇文章也是围绕这幅图详细分析. 背景 假设这是你的APP,以此为背景,下面的每个part请结合上图理解. #Case 1 当按下app启 ...

  8. 每周.NET前沿技术文章摘要(2017-06-07)

    汇总国外.NET社区相关文章,覆盖.NET ,ASP.NET等内容: .NET .NET Core and .NET Framework Working Together, Or: The Magic ...

  9. 正则表达式 cheat sheet

  10. 653. Two Sum IV - Input is a BST

    Given a Binary Search Tree and a target number, return true if there exist two elements in the BST s ...