結果

問題 No.1623 三角形の制作
ユーザー elphe
提出日時 2024-12-10 17:29:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 880 bytes
コンパイル時間 812 ms
コンパイル使用メモリ 74,604 KB
最終ジャッジ日時 2025-02-26 11:49:13
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdint>
#include <vector>

using namespace std;

int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	uint32_t n, i, j, k;
	cin >> n;
	vector<uint16_t> r(n), g(n), b(n);
	for (i = 0; i != n; ++i) cin >> r[i];
	for (j = 0; j != n; ++j) cin >> g[j];
	for (k = 0; k != n; ++k) cin >> b[k];

	vector<uint32_t> count_r(3001, 0), count_g(3001, 0), count_b(3001, 0);
	for (i = 0; i != n; ++i) ++count_r[r[i]];
	for (j = 0; j != n; ++j) ++count_g[g[j]];
	for (k = 0; k != n; ++k) ++count_b[b[k]];

	uint64_t ans = 0;
	vector<uint32_t> sum_count_b(3001);
	sum_count_b[0] = 0;
	for (k = 1; k <= 3000; ++k)
		sum_count_b[k] = sum_count_b[k - 1] + count_b[k];

	for (i = 1; i <= 3000; ++i)
		for (j = 1; j <= i; ++j)
			ans += static_cast<uint64_t>(count_r[i]) * count_g[j] * (sum_count_b[i] - sum_count_b[i - j]);

	cout << ans << '\n';
	return 0;
}
0