Submission #3963610


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/
 
 
 
 
 
 
 
 
 
 
 
int N, A[303], C[4];
double dp[303][303][303];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) C[A[i]]++;

    rep(c3, 0, N + 1) rep(c2, 0, N + 1) rep(c1, 0, N + 1) {
        int sm = c1 + c2 + c3;
        if (sm == 0) continue;

        dp[c1][c2][c3] = 1.0 * N / sm;
        if (c1) dp[c1][c2][c3] += dp[c1 - 1][c2][c3] * c1 / sm;
        if (c2) dp[c1][c2][c3] += dp[c1 + 1][c2 - 1][c3] * c2 / sm;
        if (c3) dp[c1][c2][c3] += dp[c1][c2 + 1][c3 - 1] * c3 / sm;
    }

    printf("%.10f\n", dp[C[1]][C[2]][C[3]]);
}

Submission Info

Submission Time
Task J - Sushi
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1946 Byte
Status AC
Exec Time 576 ms
Memory 217344 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 22
Set Name Test Cases
All 0_00, 0_01, 0_02, 0_03, 1_00, 1_01, 1_02, 1_03, 1_04, 1_05, 1_06, 1_07, 1_08, 1_09, 1_10, 1_11, 1_12, 1_13, 1_14, 1_15, 1_16, 1_17
Case Name Status Exec Time Memory
0_00 AC 2 ms 2304 KB
0_01 AC 1 ms 256 KB
0_02 AC 1 ms 256 KB
0_03 AC 2 ms 6528 KB
1_00 AC 1 ms 256 KB
1_01 AC 1 ms 256 KB
1_02 AC 1 ms 256 KB
1_03 AC 562 ms 217344 KB
1_04 AC 564 ms 217344 KB
1_05 AC 565 ms 217344 KB
1_06 AC 568 ms 217344 KB
1_07 AC 562 ms 217344 KB
1_08 AC 563 ms 217344 KB
1_09 AC 576 ms 217344 KB
1_10 AC 537 ms 213248 KB
1_11 AC 538 ms 213248 KB
1_12 AC 510 ms 209152 KB
1_13 AC 566 ms 217344 KB
1_14 AC 552 ms 215296 KB
1_15 AC 561 ms 217344 KB
1_16 AC 562 ms 215296 KB
1_17 AC 565 ms 217344 KB