結果

問題 No.1590 Random Shopping
ユーザー kotatsugamekotatsugame
提出日時 2021-07-08 23:05:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 243 ms / 5,000 ms
コード長 717 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 71,408 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 05:31:30
合計ジャッジ時間 3,630 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 7 ms
4,376 KB
testcase_12 AC 21 ms
4,376 KB
testcase_13 AC 78 ms
4,380 KB
testcase_14 AC 240 ms
4,376 KB
testcase_15 AC 241 ms
4,380 KB
testcase_16 AC 243 ms
4,380 KB
testcase_17 AC 240 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 241 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 240 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 240 ms
4,376 KB
testcase_24 AC 240 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<iomanip>
using namespace std;
int N;
int A[500],R[500];
double dp[2][501];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<N;i++)cin>>R[i];
	double ans=0;
	for(int i=0;i<N;i++)
	{
		int now=0;
		for(int j=0;j<=N;j++)dp[now][j]=0;
		dp[now][0]=1;
		for(int j=0;j<N;j++)
		{
			if(j<=i?A[j]<=A[i]:A[j]<A[i])
			{
				for(int k=N;k--;)dp[now][k+1]=dp[now][k];
				dp[now][0]=0;
			}
			int nxt=1-now;
			for(int k=0;k<=N;k++)dp[nxt][k]=0;
			for(int k=0;k<=N;k++)
			{
				dp[nxt][k?k-1:0]+=dp[now][k]/2;
				dp[nxt][k]+=dp[now][k]/2;
			}
			if(j>=i)
			{
				ans+=dp[nxt][0]*R[j]*A[i];
				dp[nxt][0]=0;
			}
			now=nxt;
		}
	}
	cout<<fixed<<setprecision(16)<<ans<<endl;
}
0