Unique Ascending Array


Time Limit: 2 Seconds      Memory Limit: 65536 KB


Given an array of integers A[N], you are asked to decide the shortest array of integers B[M], such that the following two conditions hold.

  • For all integers 0 <= i < N, there exists an integer 0 <= j < M, such that A[i] == B[j]
  • For all integers 0 =< i < j < M, we have B[i] < B[j]

Notice that for each array A[] a unique array B[] exists.

Input

The input consists of several test cases. For each test case, an integer N (1 <= N <= 100) is given, followed by N integers A[0], A[1], ..., A[N - 1] in a line. A line containing only
a zero indicates the end of input.

Output

For each test case in the input, output the array B in one line. There should be exactly one space between the numbers, and there should be no initial or trailing spaces.

Sample Input

8 1 2 3 4 5 6 7 8

8 8 7 6 5 4 3 2 1

8 1 3 2 3 1 2 3 1

0

Sample Output

1 2 3 4 5 6 7 8

1 2 3 4 5 6 7 8

1 2 3

————————————————————————————————————

题目的意思是给出一个序列,输出去重后的排序好的序列

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue> using namespace std;
#define inf 0x3f3f3f3f int main()
{
int n,a[100005];
while(~scanf("%d",&n)&&n)
{
for(int i=0; i<n; i++)
scanf("%d",&a[i]);
sort(a,a+n);
printf("%d",a[0]);
for(int i=1; i<n; i++)
if(a[i]!=a[i-1])
printf(" %d",a[i]);
printf("\n");
}
return 0;
}

ZOJ2481 Unique Ascending Array 2017-04-18 23:08 33人阅读 评论(0) 收藏的更多相关文章

  1. PAT甲 1041. Be Unique (20) 2016-09-09 23:14 33人阅读 评论(0) 收藏

    1041. Be Unique (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Being uniqu ...

  2. POJ1679 The Unique MST 2017-04-15 23:34 29人阅读 评论(0) 收藏

    The Unique MST Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 29902   Accepted: 10697 ...

  3. java生成UUID通用唯一识别码 (Universally Unique Identifier) 分类: B1_JAVA 2014-08-22 16:09 331人阅读 评论(0) 收藏

    转自:http://blog.csdn.net/carefree31441/article/details/3998553 UUID含义是通用唯一识别码 (Universally Unique Ide ...

  4. NYOJ-235 zb的生日 AC 分类: NYOJ 2013-12-30 23:10 183人阅读 评论(0) 收藏

    DFS算法: #include<stdio.h> #include<math.h> void find(int k,int w); int num[23]={0}; int m ...

  5. HDU2033 人见人爱A+B 分类: ACM 2015-06-21 23:05 13人阅读 评论(0) 收藏

    人见人爱A+B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...

  6. Hdu 1009 FatMouse' Trade 2016-05-05 23:02 86人阅读 评论(0) 收藏

    FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...

  7. ZOJ2482 IP Address 2017-04-18 23:11 44人阅读 评论(0) 收藏

    IP Address Time Limit: 2 Seconds      Memory Limit: 65536 KB Suppose you are reading byte streams fr ...

  8. PAT甲 1048. Find Coins (25) 2016-09-09 23:15 29人阅读 评论(0) 收藏

    1048. Find Coins (25) 时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Eva loves t ...

  9. HDU1301&&POJ1251 Jungle Roads 2017-04-12 23:27 40人阅读 评论(0) 收藏

    Jungle Roads Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 25993   Accepted: 12181 De ...

随机推荐

  1. Haskell语言学习笔记(51)Comonad

    Comonad class Functor w => Comonad w where extract :: w a -> a duplicate :: w a -> w (w a) ...

  2. JavaScript eval_r() 函数

    定义和用法 eval_r() 函数可计算某个字符串,并执行其中的的 JavaScript 代码. 语法 eval_r(string) 参数 描述 string 必需.要计算的字符串,其中含有要计算的  ...

  3. HttpClientUtil 工具类

    /* * * * FileName: s.java * * Description:TODO(用一句话描述该文件做什么) * * Created: jiangzhanghong 2017年11月14日 ...

  4. centos7 opencc 安装

    繁体字转换:http://xh.5156edu.com/jtof.php 转换的有问题http://tool.lu/zhconvert/ git网址:https://github.com/BYVoid ...

  5. DEXSeq

    1)Introduction DEXSeq是一种在多个比较RNA-seq实验中,检验差异外显子使用情况的方法. 通过差异外显子使用(DEU),我们指的是由实验条件引起的外显子相对使用的变化. 外显子的 ...

  6. Baidu URL的部分参数

    [Baidu URL的部分参数] 1.Baidu Form表单如下: 2.部分参数解析 wd  查询关键字,就是你要搜索的内容. bs 上一次搜索的词或者内容: rn  搜索结果页每页显示的数目,默认 ...

  7. 解决windows 下mysql 表名自动转成小写的问题

    由于web用的是mvc,数据库用的是mysql.为了方便开发,在windows7下面也安装了个mysql,今天在创建表的时候,遇到了个棘手的问题.所有的表名都转成了小写,这不是我要的,作为处女座,是不 ...

  8. Android自定义实现微信标题栏

    Android自定义实现微信标题栏     前言:在android的开发中有时我们需要更个性化的标题栏,而不仅仅是系统预定义的图标加软件名,同时有时候我们需要在标题栏中实现更多功能,如添加按钮响应用户 ...

  9. clear(), evict(), flush()三种方法的用法实例

    先贴代码: @Before public void init() { System.out.println("Test开始之前执行"); Configuration configu ...

  10. pre换行段落间距

    <!DOCTYPE html><html><head lang="en"><meta charset="UTF-8"& ...