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. Ubuntu 安装 Elasticsearch

    1.安装java 注意:最新版本的elasticsearch(5.6.2)要求安装java8 1.sudo apt-add-repository ppa:webupd8team/java 2.sudo ...

  2. homewor

    <jsp;include>动作和指令的区别: 一:执行时间上: <%@ include file=”relativeURI”%>                   是在翻译阶 ...

  3. Ansible 从远程主机添加或删除MySQL数据库

    mysql_db - 从远程主机添加或删除MySQL数据库. 概要 要求(在执行模块的主机上) 选项 例子 笔记 状态 支持 概要 从远程主机添加或删除MySQL数据库. 要求(在执行模块的主机上) ...

  4. C#语法基础

    泛型 1.default(T)可以返回T类型的空值,因为你不知道T是值类型还是引用类型,所以别擅自用null 2.泛型约束 很多时候我们不希望使用者太过自由 我们希望他们在使用我们设计的泛型类型时 不 ...

  5. Golang 获取MD5的方法

    import ( "crypto/md5" "encoding/hex" ) //生成32位md5字串 func Md5(s string) string { ...

  6. struts2标签类别

    要在jsp中使用Struts2的标志,先要指明标志的引入.通过jsp的代码的顶部加入以下的代码: <%@taglib prefix="s" uri="/struts ...

  7. js join 与 split

    var a = [] var b = [1,2,3] b.push('4')   // b = [1,2,3,4] a = b.join('-')  // a = '1-2-3-4' b = a.sp ...

  8. cdoj第13th校赛初赛L - Lovely princess

    http://acm.uestc.edu.cn/#/contest/show/54 L - Lovely princess Time Limit: 3000/1000MS (Java/Others) ...

  9. Winform关于OpenFileDialog的使用方法

    1.OpenFileDialog控件有以下基本属性InitialDirectory 对话框的初始目录Filter 要在对话框中显示的文件筛选器,例如,"文本文件(*.txt)|*.txt|所 ...

  10. c++ stl常用

    #include<iostream>#include<string>#include<vector>#include<list>#include< ...