結果

問題 No.108 トリプルカードコンプ
ユーザー roarisroaris
提出日時 2019-11-09 01:41:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 759 bytes
コンパイル時間 1,527 ms
コンパイル使用メモリ 164,008 KB
実行使用メモリ 14,116 KB
最終ジャッジ日時 2023-10-13 06:33:20
合計ジャッジ時間 2,894 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
13,868 KB
testcase_01 AC 6 ms
14,068 KB
testcase_02 AC 5 ms
14,024 KB
testcase_03 AC 6 ms
13,872 KB
testcase_04 AC 6 ms
14,040 KB
testcase_05 AC 6 ms
14,036 KB
testcase_06 AC 5 ms
13,844 KB
testcase_07 AC 8 ms
13,928 KB
testcase_08 AC 5 ms
13,936 KB
testcase_09 AC 5 ms
13,888 KB
testcase_10 AC 5 ms
13,912 KB
testcase_11 AC 5 ms
13,928 KB
testcase_12 WA -
testcase_13 AC 6 ms
13,904 KB
testcase_14 AC 6 ms
14,056 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 5 ms
13,904 KB
testcase_18 AC 8 ms
13,936 KB
testcase_19 AC 6 ms
14,036 KB
testcase_20 AC 5 ms
13,892 KB
testcase_21 AC 7 ms
14,044 KB
testcase_22 AC 6 ms
14,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long

int N;
double memo[110][110][110];

double rec(int i, int j, int k) {
    if (memo[i][j][k] >= 0) return memo[i][j][k];
     
    double res = 0;
    
    if (i > 0) res += i*rec(i-1, j+1, k);
    if (j > 0) res += j*rec(i, j-1, k+1);
    if (k > 0) res += k*rec(i, j, k-1);
    res += N;
    res /= i+j+k;
    
    return memo[i][j][k] = res;
}

signed main() {
    cin >> N;
    int zero=0, one=0, two=0;
    
    for (int i=0; i<N; i++) {
        int ai; cin >> ai;
        
        if (ai == 0) zero++;
        else if (ai == 1) one++;
        else if (ai == 2) two++;
    }
    
    memset(memo, -1, sizeof(memo));
    memo[0][0][0] = 0;
    
    cout << rec(zero, one, two) << endl;
}
0