結果

問題 No.1590 Random Shopping
ユーザー chocoruskchocorusk
提出日時 2021-07-08 23:00:52
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 477 ms / 5,000 ms
コード長 1,696 bytes
コンパイル時間 3,036 ms
使用メモリ 9,632 KB
最終ジャッジ日時 2023-02-01 19:06:05
合計ジャッジ時間 8,582 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 4 ms
7,532 KB
testcase_01 AC 4 ms
7,540 KB
testcase_02 AC 4 ms
7,724 KB
testcase_03 AC 4 ms
7,616 KB
testcase_04 AC 4 ms
7,552 KB
testcase_05 AC 4 ms
7,628 KB
testcase_06 AC 4 ms
7,636 KB
testcase_07 AC 5 ms
7,608 KB
testcase_08 AC 5 ms
7,744 KB
testcase_09 AC 8 ms
7,848 KB
testcase_10 AC 16 ms
7,968 KB
testcase_11 AC 35 ms
8,108 KB
testcase_12 AC 85 ms
8,460 KB
testcase_13 AC 215 ms
9,044 KB
testcase_14 AC 474 ms
9,584 KB
testcase_15 AC 474 ms
9,508 KB
testcase_16 AC 474 ms
9,508 KB
testcase_17 AC 474 ms
9,632 KB
testcase_18 AC 4 ms
7,556 KB
testcase_19 AC 473 ms
9,504 KB
testcase_20 AC 3 ms
7,552 KB
testcase_21 AC 473 ms
9,628 KB
testcase_22 AC 4 ms
7,648 KB
testcase_23 AC 474 ms
9,620 KB
testcase_24 AC 477 ms
9,624 KB
testcase_25 AC 4 ms
7,536 KB
testcase_26 AC 4 ms
7,588 KB
testcase_27 AC 4 ms
7,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
double dp[505][505];
int main()
{
    int n; cin>>n;
    int a[505], r[505];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    for(int i=0; i<n; i++){
        cin>>r[i];
    }
    double p[505][1010]={};
    for(int i=1; i<=1001; i++){
        for(int j=0; j<=n; j++) for(int k=0; k<=j; k++) dp[j][k]=0;
        dp[0][0]=1;
        for(int j=0; j<n; j++){
            for(int k=0; k<=j; k++){
                if(a[j]>=i){
                    if(k>0){
                        dp[j+1][k-1]+=dp[j][k]*0.5;
                        dp[j+1][k]+=dp[j][k]*0.5;
                        p[j][i]+=dp[j][k]*0.5;
                    }else{
                        dp[j+1][k]+=dp[j][k];
                    }
                }else{
                    dp[j+1][k]+=dp[j][k]*0.5;
                    dp[j+1][k+1]+=dp[j][k]*0.5;
                    p[j][i]+=dp[j][k]*0.5;
                }
            }
        }
    }
    double ans=0;
    for(int i=1; i<=1000; i++){
        for(int j=0; j<n; j++){
            ans+=r[j]*i*(p[j][i+1]-p[j][i]);
        }
    }
    printf("%.8lf\n", ans);
    return 0;
}
0