AcWing 1204. 错误票据
原题链接
简单
作者:
Nazarena
,
2021-01-09 11:21:52
,
所有人可见
,
阅读 4
C++ 代码
#include<iostream>
#include<algorithm>
using namespace std;
const int M = 100000;
int main()
{
int arr[M],num,len,i=0;
int m,n,temp;//m表示断号ID,n 表示重号ID
cin>>len;
while(len--)
{
while(cin>>num)
{
arr[i]=num;
i++; //最终数组是i个长度
}
}
sort(arr,arr+i);
/*for(int j=0;j<i;j++)
cout<<arr[j]<<" ";
cout<<""<<endl; */
temp=arr[0];
for(int j=1;j<i;j++)
{
if(temp==arr[j])
n=temp;
else if(temp+1==arr[j])
temp=arr[j];
else
{
m=temp+1;
temp=temp+2;
}
}
cout<<m<<" "<<n<<"";
return 0;
}