Problem Code:BUTYPAIR
Although my code is giving AC,I am not sure about the time complexity of it. Can somebody tell me how can I calculate it?
#include "bits/stdc++.h"
#define ll long long int
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;
cin >> t;
while (t--)
{
map<double, ll> freq;
ll n;
cin >> n;
vector<double> arr(n);
for (ll i = 0; i < n; i++)
{
cin >> arr[i];
freq[arr[i]]++;
}
sort(arr.begin(), arr.end());
ll count = 0;
for (ll i = 0; i < n; i += freq[arr[i]])
{
ll j = i + freq[arr[i]];
if (j <= n - 1)
count += (n - j) * freq[arr[i]];
}
cout << count * 2 << endl;
}
return 0;
}```