結果

問題 No.118 門松列(2)
ユーザー 古寺いろは古寺いろは
提出日時 2015-04-08 00:40:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 1,052 bytes
コンパイル時間 1,452 ms
コンパイル使用メモリ 167,032 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 12:57:20
合計ジャッジ時間 2,916 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 23 ms
5,376 KB
testcase_02 AC 23 ms
5,376 KB
testcase_03 AC 22 ms
5,376 KB
testcase_04 AC 22 ms
5,376 KB
testcase_05 AC 23 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 20 ms
5,376 KB
testcase_10 AC 5 ms
5,376 KB
testcase_11 AC 7 ms
5,376 KB
testcase_12 AC 5 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 22 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 12 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 8 ms
5,376 KB
testcase_19 AC 11 ms
5,376 KB
testcase_20 AC 12 ms
5,376 KB
testcase_21 AC 19 ms
5,376 KB
testcase_22 AC 6 ms
5,376 KB
testcase_23 AC 17 ms
5,376 KB
testcase_24 AC 8 ms
5,376 KB
testcase_25 AC 11 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	map<int, int> m1;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		m1[A[i]]++;
	}
	map<int, int> m2;
	for (auto i : m1){
		m2[i.second]++;
	}

	long long mod = (long long)1e9 + 7;
	long long ans = 0;
	for (auto i: m2)
	{
		for (auto j : m2)
		{
			if (i.first <= j.first) continue;
			for (auto k : m2)
			{
				if (i.first <= k.first) continue;
				if (j.first <= k.first) continue;
				ans += (long long)i.first * j.first % mod * k.first % mod * i.second % mod * j.second % mod * k.second % mod;
				ans %= mod;
			}
		}
	}

	for (auto i : m2)
	{
		for (auto j : m2)
		{
			if (i == j) continue;
			ans += (long long)i.first * i.first % mod * j.first % mod * ((long long)i.second * (i.second - 1) / 2) % mod * j.second % mod;
			ans %= mod;
		}
	}

	for (auto i : m2)
	{
		ans += (long long)i.first * i.first % mod * i.first % mod * (((long long)(i.second) * (i.second - 1) * (i.second - 2) / 6) % mod) % mod;
		ans %= mod;
	}
	cout << ans << endl;
}
0