Untitled

 avatar
unknown
plain_text
7 days ago
410 B
3
Indexable
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6+1;
long long n, th, t, a[N], d[N];
int main(){
	cin >> n;	
	for (int i = 1; i <= n; i++){
		cin >> a[i];
		d[a[i]]++;
	}
	th = n * ( n - 1 ) / 2;
	t = 0;
	for (int i = 1; i <= n; i++){
		cout << d[a[i]] << " : " << a[i] << endl;
		if (d[a[i]] >= 2){
			t += d[a[i]] * ( d[a[i]] - 1 ) / 2;
		}
	}
	cout << t;
	return 0;
}
Editor is loading...
Leave a Comment