結果

問題 No.1470 Mex Sum
コンテスト
ユーザー nok0
提出日時 2021-04-04 11:10:38
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.90.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 509 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 6,144 ms
コンパイル使用メモリ 336,000 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-19 11:53:23
合計ジャッジ時間 7,739 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 2
other RE * 49
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

long long x, y, z;
int main() {
	registerValidation();
	int n;
	n = inf.readInt(2, 200000);
	vector a(n, 0);
	for(int i = 0; i < n; i++) {
		if(i) inf.readSpace();
		a[i] = inf.readInt(1, 1000000000);
	}
	inf.readEoln();
	inf.readEof();
	x = count(a.begin(), a.end(), 1);
	y = count(a.begin(), a.end(), 2);
	z = n - x - y;
	cout << x * y * 3 + (x * (x - 1) / 2 + x * z) * 2 + (z * y + z * (z - 1) / 2 + y * (y - 1) / 2) << endl;
	return 0;
}
0