AcWing 1204. 错误票据
原题链接
简单
作者:
隐灵
,
2024-03-13 19:01:05
,
所有人可见
,
阅读 7
#include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
using namespace std;
const int N = 10010;
int n;
int a[N];
int main()
{
int cnt; //行数
cin >> cnt; //读入后会有一个回车
string line;
getline(cin, line); //过滤掉读入后的回车,即忽略掉第一行的回车
while(cnt -- )
{
getline(cin, line);
stringstream ssin(line);
while (ssin >> a[n]) n ++ ;
}
sort(a, a + n); //例如:5 6 8 9 9 11 12
int res1, res2; //res1表示断号,res2表示重号
for (int i = 1; i < n; i ++ )
if (a[i] == a[i - 1]) res2 = a[i];
else if (a[i] - a[i - 1] > 1) res1 = a[i] - 1;
cout << res1 << ' ' << res2 << endl;
return 0;
}