結果

問題 No.1470 Mex Sum
ユーザー cookiedothcookiedoth
提出日時 2021-04-09 21:30:47
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 4,744 bytes
コンパイル時間 2,648 ms
コンパイル使用メモリ 133,744 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 10:00:06
合計ジャッジ時間 3,847 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 14 ms
4,380 KB
testcase_13 AC 15 ms
4,380 KB
testcase_14 AC 14 ms
4,376 KB
testcase_15 AC 15 ms
4,376 KB
testcase_16 AC 15 ms
4,380 KB
testcase_17 AC 14 ms
4,380 KB
testcase_18 AC 15 ms
4,376 KB
testcase_19 AC 15 ms
4,376 KB
testcase_20 AC 15 ms
4,380 KB
testcase_21 AC 15 ms
4,380 KB
testcase_22 AC 15 ms
4,380 KB
testcase_23 AC 15 ms
4,376 KB
testcase_24 AC 15 ms
4,380 KB
testcase_25 AC 15 ms
4,380 KB
testcase_26 AC 15 ms
4,376 KB
testcase_27 AC 15 ms
4,384 KB
testcase_28 AC 15 ms
4,376 KB
testcase_29 AC 15 ms
4,376 KB
testcase_30 AC 15 ms
4,380 KB
testcase_31 AC 15 ms
4,380 KB
testcase_32 AC 15 ms
4,380 KB
testcase_33 AC 15 ms
4,380 KB
testcase_34 AC 15 ms
4,380 KB
testcase_35 AC 15 ms
4,380 KB
testcase_36 AC 15 ms
4,376 KB
testcase_37 AC 12 ms
4,380 KB
testcase_38 AC 12 ms
4,376 KB
testcase_39 AC 12 ms
4,380 KB
testcase_40 AC 12 ms
4,380 KB
testcase_41 AC 13 ms
4,380 KB
testcase_42 AC 13 ms
4,380 KB
testcase_43 AC 12 ms
4,384 KB
testcase_44 AC 12 ms
4,380 KB
testcase_45 AC 12 ms
4,380 KB
testcase_46 AC 12 ms
4,376 KB
testcase_47 AC 12 ms
4,380 KB
testcase_48 AC 12 ms
4,376 KB
testcase_49 AC 12 ms
4,380 KB
testcase_50 AC 13 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*

Code for problem B by cookiedoth
Generated 09 Apr 2021 at 03.27 PM


СТРОИМ КОММУНИЗМ РАБОТЯГИ!
 
                                    ╦═╩═╦═╩═█
                          ████▄▄▄═╦═╩═╦═╩═╦═█
                  ████████████████▄▄╦═╩═╦═╩═█
█═╦═╩═╦▄████████████████▀▀▀▀█████████▄╦═╩═╦═█
█═╩═╦═████████████████████▄═╦▀█████████═╦═╩═█
█═╦═▄██████████▀╩═╦═╩▄██████▄═╦▀████████▄═╦═█
█═╩═█████████▀╩═╦═╩═█████████▄╩═╦████████═╩═█
█═╦█████████▄═╦═╩═╦═▀█████████╦═╩═████████╦═█
█═╩███████████▄▄██▄═╦═▀████████═╦═████████╩═█
█═██████████████████▄═╦═▀█████▀═╩═█████████═█
█═████████████████████▄═╦═▀███╩═╦═█████████═█
█═╦████████████▀╩▀██████▄═╦═▀═╦═╩█████████╦═█
█═╩█████████▀═╩═╦═╩▀▀███▀▀╩═╦═╩═██████████╩═█
█═╦═██████▀═╦═▄▄█▄▄═╩═╦═╩═╦═╩═╦═╩▀███████═╦═█
█═╩═▀████═╩═▄█████████▄▄▄▄████▄═╦═╩█████▀═╩═█
█═╦═╩═██████████████████████████▄═▄████═╩═╦═█
█═╩═╦═╩▀█████████████████████████████▀╩═╦═╩═█
█═╦═╩═╦═╩▀▀███████████████████████▀▀╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═▀▀▀███████████████▀▀▀═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═▀▀▀▀▀▀▀▀▀═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█

-_-
z_z
=_=

*/

#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#include <numeric>
#include <random>
#include <utility>
#include <tuple>
#include <chrono>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define debug(a) cerr << #a << " = " << a << endl
#define forn(i, n) for (int i = 0; i < n; ++i)
#define length(a) (int)a.size()

using namespace std;

template<class T> int chkmax(T &a, T b) {
	if (b > a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T> int chkmin(T &a, T b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class iterator> void output(iterator begin, iterator end, ostream& out = cerr) {
	while (begin != end) {
		out << (*begin) << " ";
		begin++;
	}
	out << endl;
}

template<class T> void output(T x, ostream& out = cerr) {
	output(x.begin(), x.end(), out);
}

void fast_io() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

signed main() {
	fast_io();
	vector<ll> cnt(4);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int val;
		cin >> val;
		if (val > 3) {
			val = 3;
		}
		cnt[val]++;
	}
	ll ans = 0;
	for (int i = 1; i <= 3; ++i) {
		for (int j = i; j <= 3; ++j) {
			ll ways = (i == j ? (cnt[i] * (cnt[i] - 1) / 2) : cnt[i] * cnt[j]);
			ll mx = 1;
			if (i == 1) {
				mx = 2;
			}
			if (i == 1 && j == 2) {
				mx = 3;
			}
			ans += ways * mx;
		}
	}
	cout << ans << '\n';
}
0