coderhelp234 | Unsorted

Telegram-канал coderhelp234 - Juspay exam Solution | Codeforces div 2 free solution| Codechef| Codeforces| Atcoder| free solution

767

@Codeforces_Codechef_freesolution

Subscribe to a channel

Juspay exam Solution | Codeforces div 2 free solution| Codechef| Codeforces| Atcoder| free solution

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

#define int long long

int32_t main()
{
int t;
cin>>t;

while(t--)
{
int n;
cin>>n;

vector<int>vec(n);

for(int i=0;i<n;i++)
{
cin>>vec[i];
}

vector<int>store(101,0);

for(int i=0;i<n;i++)
{
store[vec[i]]++;
}

int some=store[0];
int maxi=0;
int ind=-1;

//cout<<some<<endl;

for(int i=1;i<=100;i++)
{
// maxi=max(maxi,store[i]);

if(store[i]>maxi)
{
maxi=store[i];
ind=i;
}
}

maxi=maxi+some;
//cout<<maxi<<endl;

maxi--;

int ans=maxi*(maxi+1)/2;

for(int i=1;i<=100;i++)
{
if(i!=ind)
{
ans+=(store[i]-1)*(store[i])/2;
}

}

cout<<ans<<endl;


}
return 0;
}

// Equal pairs easy

Читать полностью…
Subscribe to a channel