結果

問題 No.108 トリプルカードコンプ
ユーザー auauaauaua
提出日時 2020-02-08 23:19:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,141 bytes
コンパイル時間 1,704 ms
コンパイル使用メモリ 168,968 KB
実行使用メモリ 24,832 KB
最終ジャッジ日時 2024-04-08 11:37:38
合計ジャッジ時間 3,437 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 18 ms
24,832 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 19 ms
24,832 KB
testcase_06 AC 19 ms
24,832 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 21 ms
24,832 KB
testcase_11 AC 23 ms
24,832 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<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
ll n;
vector<vector<vector<double> > >dp(110,vector<vector<double> >(110,vector<double>(110)));
vector<ll>cnt(4);
double solve(ll x,ll y,ll z){
    if(dp[x][y][z]!=-1)return dp[x][y][z];
    dp[x][y][z]=0;
    double k=1.0*n/(n-z);
    if(x!=n)dp[x][y][z]+=(solve(x+1,y,z)+k)*(n-x)/(n-z);
    if(x!=y)dp[x][y][z]+=(solve(x,y+1,z)+k)*(x-y)/(n-z);
    if(y!=z)dp[x][y][z]+=(solve(x,y,z+1)+k)*(z-y)/(n-z);
    return dp[x][y][z];
}
int main(){
    cin>>n;
    rep(i,n+1)rep(j,n+1)rep(k,n+1)dp[i][j][k]=-1;
    rep(i,n){
        ll a;cin>>a;
        cnt[min(a,3LL)]++;
    }
    for(int i=2;i>=0;i--){
        cnt[i]+=cnt[i+1];
    }
    dp[n][n][n]=0;
    cout<<fixed<<setprecision(10)<<solve(cnt[1],cnt[2],cnt[3])<<endl;
}
0