Time limit(ms): 3000    Memory limit(kb): 65535
 

hzf is crazy about reading math recently,and he is thinking about a boring problem.

Now there are n integers Arranged in a line.For each integer,he wants to know the maximum integer in its left which is less than it.

Description

The input consists of multiple test cases.

For each case,the first line contains one integer n(0<n<=100000),indicating the number of integers.

The second line contains n integers,indicating the integers from left to right,marked a1…an.(0<ai<=10^9).

Input

For each case,there are n integers,indicating the maximum integer in ai's left which is less than it.If it doesn's exist,output -1.

Output
1
2
3
4
5
1 2 3 4 5
5
5 4 3 2 1
Sample Input
1
2
-1 1 2 3 4
-1 -1 -1 -1 -1
Sample Output
由于OJ上传数据的BUG,换行请使用"\r\n",非常抱歉

题目大意:给你一排数字,在这个状态下,在当前数的左边找比它小的最大数字,没有就是-1

思路:这个题说白了就是一个容器set的用法(当然其他方法也可以),这个头文件类有点多
给个知识链接:http://www.cnblogs.com/zyxStar/p/4542835.html代码如下
 #include <iostream>
#include <set>
using namespace std;
int n, x[];
int main(){
while (cin >> n){
set<int>mpt;
set<int>::iterator it;
int i, k;
for (i = ; i < n; i++){
cin >> x[i];
k = x[i];
it = mpt.lower_bound(x[i]);
if (it == mpt.begin()) x[i] = -;
else{
it--;
x[i] = *it;
}
mpt.insert(k);
}
for (i = ; i < n; i++){
if (i) cout << ' ';
cout << x[i];
}
cout << "\r\n";
}
return ;
}

有时候巧用容器也是不错的~~~

[Swust OJ 1026]--Egg pain's hzf的更多相关文章

  1. [Swust OJ 404]--最小代价树(动态规划)

    题目链接:http://acm.swust.edu.cn/problem/code/745255/ Time limit(ms): 1000 Memory limit(kb): 65535   Des ...

  2. [Swust OJ 649]--NBA Finals(dp,后台略(hen)坑)

    题目链接:http://acm.swust.edu.cn/problem/649/ Time limit(ms): 1000 Memory limit(kb): 65535 Consider two ...

  3. SWUST OJ NBA Finals(0649)

    NBA Finals(0649) Time limit(ms): 1000 Memory limit(kb): 65535 Submission: 404 Accepted: 128   Descri ...

  4. [Swust OJ 1023]--Escape(带点其他状态的BFS)

    解题思路:http://acm.swust.edu.cn/problem/1023/ Time limit(ms): 5000 Memory limit(kb): 65535     Descript ...

  5. [Swust OJ 1125]--又见GCD(数论,素数表存贮因子)

    题目链接:http://acm.swust.edu.cn/problem/1125/ Time limit(ms): 1000 Memory limit(kb): 65535   Descriptio ...

  6. [Swust OJ 1126]--神奇的矩阵(BFS,预处理,打表)

    题目链接:http://acm.swust.edu.cn/problem/1126/ Time limit(ms): 1000 Memory limit(kb): 65535 上一周里,患有XX症的哈 ...

  7. [Swust OJ 1139]--Coin-row problem

    题目链接:  http://acm.swust.edu.cn/contest/0226/problem/1139/ There is a row of n coins whose values are ...

  8. [Swust OJ 385]--自动写诗

    题目链接:http://acm.swust.edu.cn/problem/0385/ Time limit(ms): 5000 Memory limit(kb): 65535    Descripti ...

  9. [Swust OJ 403]--集合删数

    题目链接:http://acm.swust.edu.cn/problem/403/ Time limit(ms): 5000 Memory limit(kb): 65535   Description ...

随机推荐

  1. HDU2005-第几天

    描述: 给定一个日期,输出这个日期是该年的第几天. 代码: #include<stdio.h> #include<string.h> #include<iostream& ...

  2. HTML+CSS笔记 CSS进阶续集

    元素分类 在CSS中,html中的标签元素大体被分为三种不同的类型:块状元素.内联元素(又叫行内元素)和内联块状元素. 常用的块状元素有: <div>.<p>.<h1&g ...

  3. Android UiAutomator 自动化测试环境搭建---新手1

    1.首先需要准备的工具有 1.java jdk 2. android开发工具 adt 3.ant 安装包(如果下载adt里面有) 2.首先安装java环境,jdk这个百度就可以了. 3.android ...

  4. Docker背后的容器管理——Libcontainer深度解析

    Libcontainer 是Docker中用于容器管理的包,它基于Go语言实现,通过管理namespaces.cgroups.capabilities以及文件系统来进行容器控制.你可以使用Libcon ...

  5. eclipse编译错误

    ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2 JDWP exit error AGE ...

  6. 用于展现图表的50种JavaScript库

    在很多项目中都会有在前端展现数据图表的需求,而在开发过程中,开发者往往会使用一些JavaScript库,从而更有效地达到想要的目标.最近,TechSlide上的一篇文章总结了50种用于展现图表的Jav ...

  7. Hello China操作系统STM32移植指南(三)

    移植到STM32的源代码,可从下列链接下载: http://download.csdn.net/detail/hellochina15/7049909 包含两个包:一个是移植前的Hello China ...

  8. js 常用的一些函数

    //设置默认焦点    var setFocus = function SetFocus(elementId) {        document.onkeydown = function (even ...

  9. Codeforces 18C C. Stripe

    Codeforces 18C  C. Stripe 链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86640#problem/E 题 ...

  10. C++创建对象的三种方式

    C++在创建对象的时候,有三种方式: #include <iostream> using namespace std; class A { private: int n; public: ...