算法1
(set做法)
blablabla
C++ 代码
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<set>
using namespace std;
const int maxn = 1000005;
int a[maxn],b[maxn];
int n,value,first,second;
set<int>sets;
set<int>::iterator it;
int main(void) {
cin >> n;
while(scanf("%d",&value) != EOF) {
if(sets.find(value) != sets.end()) {
first = value;
} else {
sets.insert(value);
}
}
int res = 0;
for(it = sets.begin(); it != sets.end(); it ++) {
a[res ++] = *it;
}
for(int i = 1; i < res; i ++) {
if(a[i] - a[i - 1] != 1) {
second = a[i - 1] + 1;
break;
}
}
cout<<second<<" "<<first<<endl;
return 0;
}