Help me in solving LARGESTK problem

My issue

(Largest k)can some one pl explain
this test case
1
5
1 1 1 2 3 expected ans is 4

My code

#include <bits/stdc++.h>
using namespace std;

#define ll long long 

ll k(){
        ll n;
        cin>>n;
        set<ll> s;
        vector<ll> v(n);
        for(int i = 0;i<n;i++){
            ll d;
            cin>>d;
            s.insert(d);
            v[i] = d;
        }
        if(v.size() == s.size()){
            return n;
        }
        
        ll p = s.size();
        ll a = n/p;
         
        return a * p;
        
        
}
    


int main() {
	// your code goes here
    ll t;
    cin>>t;
    while(t--){
        cout<<k()<<endl;
    }
}

Problem Link: Largest K Practice Coding Problem

you are solving for p different no. and giving output
but ans can also come from string containing 1 to p different no.

1 Like

Let take your test case
1
5
1 1 1 2 3
max ans of different no. as 1 =3
for 2 =4
for 3=3
ans= 4

1 Like

thank you

No problem just like the reply