posts - 195,  comments - 30,  trackbacks - 0
Status In/Out TIME Limit MEMORY Limit Submit Times Solved Users JUDGE TYPE
stdin/stdout 3s 40960K 1071 235 Standard
In a interger sequence S there are N(N < 1000000) intergers, there is a initial number I(-2^31 < I <2^31), which is the minimun interger in S, and no two integers are the same. Now can you find the first lost interger L make the sequence is not consecutive. For example, S = { 1, -2, 2, 9, -1 }, then I = -2, and L = 0.

Input

For each case N is in the first line, and next N lines is the sequence S.

Output

Output L for each case in a single line.

Sample Input

5
1
-2
2
9
-1

Sample Output

0
不用走入排序的误区,
可以在线性的时间内完成。
先一趟循环,保存输入的值n[MAX],同时可找出最小的值,
再来一趟循环以此为基准对每个数进行标记,对每个出现的num,mark[num-min]=1;
然后
for(int i=0;;i++)
{if(mark[i]==0)
cout<<i+min;
break;
}
----
posted on 2009-07-19 14:18 luis 阅读(324) 评论(1)  编辑 收藏 引用 所属分类: 粗心题

FeedBack:
# re: joj 2199 the lost number 好题 值得做做
2009-07-19 16:42 | crazy_coder
好方法,这题我开始时1.26s过的,汗。。。  回复  更多评论
  

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2009年7月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿(3)

随笔分类

随笔档案

文章分类

文章档案

友情链接

搜索

  •  

最新评论

阅读排行榜

评论排行榜