#include<iostream> #include<map> #include<string> using namespace std; const int N=2e5+10; typedef long long ll; //统计一下最少有多少个set集合 //思路太妙了 int n; void solve() { cin>>n; map<int,int> mp; for(int i=0;i<n;i++) { int x; cin>>x; mp[x]++; } int last=-1; int res=n; int cnt=0; for(auto p:mp) { if(p.first==last+1) res-=min(p.second,cnt); last=p.first; cnt=p.second; } cout<<res<<endl; } int main() { int T; cin>>T; while(T--) solve(); return 0; }
标签:cnt,last,int,Matryoshkas,second,mp,include From: https://www.cnblogs.com/tolter/p/17235941.html