結果

問題 No.108 トリプルカードコンプ
ユーザー kusainu7kusainu7
提出日時 2021-05-29 18:58:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 701 bytes
コンパイル時間 548 ms
コンパイル使用メモリ 71,352 KB
実行使用メモリ 14,152 KB
最終ジャッジ日時 2024-04-25 14:54:50
合計ジャッジ時間 1,435 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 11 ms
13,284 KB
testcase_11 AC 12 ms
13,160 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

double c[110][110][110] = {};

void dp(int n, int *a) {
	c[n][n][n] = 0;
	for (int i=n; i>=0; i--) {
		for (int j=n; j>=0; j--) {
			for (int k=n; k>=0; k--) {
				if (k>=n) {
					continue;
				}
				c[i][j][k] = n/(n-k);
				if (n>i) c[i][j][k] += c[i+1][j][k]*(n-i)/(n-k);
				if (i>j) c[i][j][k] += c[i][j+1][k]*(i-j)/(n-k);
				if (j>k&&i>k) c[i][j][k] += c[i][j][k+1]*(j-k)/(n-k);

			}
		}
	}
}

int main() {
	int n, x;
	cin >> n;
	int a[4] = {};

	for (int i=0; i<n; i++) {
		cin >> x;
		if (x>3) {
			a[3]++;
		} else if (x!=0) {
			a[x]++;
		}
	}
	
	for (int i=2; i>0; i--) {
		a[i] += a[i+1];
	}
	
	dp(n, a);

	cout << c[a[1]][a[2]][a[3]] << '\n';
}
0