Answers for "Chocolate Monger codechef solution in c++"

C++
0

Chocolate Monger codechef solution in c++

#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long

void solve()
{
    ll n,x;
    cin>>n>>x;
    vector<ll> v(n);
    for(ll i=0;i<n;i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    ll s=v.size();
    if(s>n-x)
    {
        s=n-x;
    }
    cout<<s<<"\n";
}

int main() {
	int t;
	cin>>t;
	while(t--)
	{
	    solve();
	}
	return 0;
}
Posted by: Guest on March-30-2022

Code answers related to "Chocolate Monger codechef solution in c++"

Browse Popular Code Answers by Language