PART 1 思路
本题只需要查找卡片中有无 的序列即可(不需要连续),如果少了,就输出少了几个。
PART 2 样例解释
- 一张都不需要取出,因为 就是一个单独的序列。
- 可以取出 (第四张 ),剩下序列为 。
- 需要全部取出(因为没有 )。
PART 3 Code
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
int n;
cin>>n;
int a[n],t=1; //t用来储存符合条件的卡牌张数
for(int i=0;i<n;i++)
{
cin>>a[i];
if(a[i]==t) t++;//查找是否有1,2,3… 的序列
}
cout<<n-t+1;//输出少了几个
return 0;
}