题目描述
某涉密单位下发了某种票据,并要在年终全部收回。
每张票据有唯一的ID号。
全年所有票据的ID号是连续的,但ID的开始数码是随机选定的。
因为工作人员疏忽,在录入ID号的时候发生了一处错误,造成了某个ID断号,另外一个ID重号。
你的任务是通过编程,找出断号的ID和重号的ID。
假设断号不可能发生在最大和最小号。
样例
2
5 6 8 11 9
10 12 9
输出样例:
开桶。用 $cnt$ 表示最大值,$st$ 为桶。
#include <bits/stdc++.h>
#define R register
#define inl inline
#define fastios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define Debug(file) freopen(file".in","r",stdin);freopen(file".out","w",stdout);
using namespace std;
int st[100005];
int n,cnt;
int main() {
cin >> n;
for(int i = 0;i < n;i ++){
int t;
while(cin >> t){
st[t] ++;
cnt = max(cnt,t);
}
}
int ans1,ans2;
for(int i = 0;i < cnt;i ++){
if(st[i] == 2){
ans2 = i;
}
if(st[i] == 0){
ans1 = i;
}
}
cout << ans1 << " " << ans2 << endl;
return 0;
}