Submission #70415506


Source Code Expand

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r) - 1;i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n; cin >> n;
	map<int, long long>mp;
	rep(i, n) {
		int a; cin >> a;
		mp[a]++;
	}
	long long ans = 0;
	for (auto[_, v] : mp) {
		long long add = v * (v - 1) / 2;
		add *= (n - v);
		ans += add;
	}
	cout << ans << endl;
	return 0;
}

Submission Info

Submission Time
Task C - Odd One Subsequence
User kwm_t
Language C++ 23 (gcc 12.2)
Score 300
Code Size 1170 Byte
Status AC
Exec Time 154 ms
Memory 15820 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 28
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3520 KiB
example_01.txt AC 1 ms 3412 KiB
hand_00.txt AC 154 ms 15820 KiB
hand_01.txt AC 10 ms 3380 KiB
hand_02.txt AC 17 ms 3432 KiB
hand_03.txt AC 1 ms 3480 KiB
hand_04.txt AC 1 ms 3464 KiB
hand_05.txt AC 10 ms 3456 KiB
random_00.txt AC 112 ms 11212 KiB
random_01.txt AC 111 ms 11356 KiB
random_02.txt AC 113 ms 11384 KiB
random_03.txt AC 108 ms 11348 KiB
random_04.txt AC 110 ms 11336 KiB
random_05.txt AC 35 ms 4708 KiB
random_06.txt AC 35 ms 4672 KiB
random_07.txt AC 36 ms 4708 KiB
random_08.txt AC 34 ms 4576 KiB
random_09.txt AC 35 ms 4724 KiB
random_10.txt AC 16 ms 3404 KiB
random_11.txt AC 17 ms 3344 KiB
random_12.txt AC 16 ms 3488 KiB
random_13.txt AC 17 ms 3540 KiB
random_14.txt AC 17 ms 3464 KiB
random_15.txt AC 10 ms 3516 KiB
random_16.txt AC 10 ms 3480 KiB
random_17.txt AC 10 ms 3400 KiB
random_18.txt AC 10 ms 3468 KiB
random_19.txt AC 10 ms 3468 KiB