AcWing 1204. 错误票据
原题链接
简单
作者:
Value
,
2020-07-08 09:01:57
,
所有人可见
,
阅读 570
#include <iostream>
#include <sstream>
using namespace std;
const int N = 1E6 + 10;
int a[N], flag[N];
int main(){
int n; cin >> n;
string s;
int k = 0;
getchar();
while(n -- ){
getline(cin, s);
stringstream scin(s);
while(scin >> a[k]) k ++ ;
}
int recome, lack;
int minv, maxv;
minv = 0x3f3f3f, maxv = -1;
for(int i = 0; i < k; i ++ ){
flag[a[i]] ++ ;
if(flag[a[i]] == 2) recome = a[i];
minv = min(minv, a[i]);
maxv = max(maxv, a[i]);
}
for(int i = minv; i < maxv; i ++ ){
if(!flag[i]) lack = i;
}
cout << lack << " " << recome << endl;
return 0;
}