結果

問題 No.1590 Random Shopping
ユーザー chocoruskchocorusk
提出日時 2021-07-08 23:00:52
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 475 ms / 5,000 ms
コード長 1,696 bytes
コンパイル時間 3,151 ms
コンパイル使用メモリ 187,300 KB
実行使用メモリ 9,728 KB
最終ジャッジ日時 2023-09-14 05:27:53
合計ジャッジ時間 8,411 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,624 KB
testcase_01 AC 4 ms
7,488 KB
testcase_02 AC 4 ms
7,528 KB
testcase_03 AC 3 ms
7,620 KB
testcase_04 AC 3 ms
7,748 KB
testcase_05 AC 4 ms
7,704 KB
testcase_06 AC 4 ms
7,552 KB
testcase_07 AC 4 ms
7,556 KB
testcase_08 AC 6 ms
7,668 KB
testcase_09 AC 8 ms
7,804 KB
testcase_10 AC 17 ms
7,852 KB
testcase_11 AC 36 ms
7,992 KB
testcase_12 AC 88 ms
8,320 KB
testcase_13 AC 218 ms
8,880 KB
testcase_14 AC 474 ms
9,492 KB
testcase_15 AC 475 ms
9,468 KB
testcase_16 AC 473 ms
9,640 KB
testcase_17 AC 473 ms
9,468 KB
testcase_18 AC 3 ms
7,688 KB
testcase_19 AC 469 ms
9,712 KB
testcase_20 AC 3 ms
7,484 KB
testcase_21 AC 474 ms
9,728 KB
testcase_22 AC 4 ms
7,496 KB
testcase_23 AC 471 ms
9,596 KB
testcase_24 AC 471 ms
9,692 KB
testcase_25 AC 4 ms
7,488 KB
testcase_26 AC 3 ms
7,528 KB
testcase_27 AC 4 ms
7,772 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