AcWing 1204. 错误票据
原题链接
简单
作者:
啥时候能学会hh
,
2025-01-17 00:21:02
,
所有人可见
,
阅读 3
C++ 代码
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector> //5 6 8 9 9 10 11
using namespace std;
const int N = 1e6;
int n,re,ans;
int main()
{
scanf("%d", &n);
vector<int>a;
vector<int>c;
int b;
while(cin>>b)
{
a.push_back(b);
}
sort(a.begin(),a.end());//排序
for (int i = a[0]; i <=a.back(); i ++ )
{
c.push_back(i);
}
// for (int i = 0; i < a.size(); i ++ ) printf("%d\n",a[i]);
for (int i = 0; i < a.size(); i ++ )
{
if(a[i]==a[i+1])
{
a.erase(a.begin() + i);
re=a[i];
// printf("%d\n",a[i]);
break;
}
}
for (int i = 0; i <=a.back(); i ++ )
{
if(a[i]!=c[i])
{
ans=c[i];
printf("%d ",c[i]);
break;
}
}
printf("%d",re);
return 0;
}