結果

問題 No.1247 ブロック登り
ユーザー kotatsugamekotatsugame
提出日時 2020-11-27 01:12:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 887 bytes
コンパイル時間 624 ms
コンパイル使用メモリ 68,144 KB
実行使用メモリ 215,224 KB
最終ジャッジ日時 2023-10-01 03:43:51
合計ジャッジ時間 6,164 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,432 KB
testcase_01 AC 2 ms
7,704 KB
testcase_02 AC 2 ms
7,468 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
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 AC 4 ms
4,792 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 42 ms
212,300 KB
testcase_25 WA -
testcase_26 AC 293 ms
215,016 KB
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N,K;
int A[300];
int ans[300];
int dp[301][300][300][2];
main()
{
	cin>>N>>K;
	for(int k=0;k<=K;k++)for(int i=0;i<N;i++)for(int j=i;j<N;j++)
	{
		dp[k][i][j][0]=dp[k][i][j][1]=-1e9;
	}
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		ans[i]=-1e9;
		dp[K][i][i][0]=A[i]*K;
	}
	for(int k=K;k>=0;k--)for(int i=0;i<N;i++)for(int j=i;j<N;j++)
	{
		if(j-i<=k)
		{
			dp[k-(j-i)][i][j][1]=max(dp[k-(j-i)][i][j][1],dp[k][i][j][0]);
			dp[k-(j-i)][i][j][0]=max(dp[k-(j-i)][i][j][0],dp[k][i][j][1]);
		}
		int L=dp[k][i][j][0],R=dp[k][i][j][1];
		if(i+k<=j)
		{
			ans[i+k]=max(ans[i+k],L);
			ans[j-k]=max(ans[j-k],R);
		}
		if(i>0&&k>0)
		{
			dp[k-1][i-1][j][0]=max(dp[k-1][i-1][j][0],L+(k-1)*A[i-1]);
		}
		if(j+1<N&&k>0)
		{
			dp[k-1][i][j+1][1]=max(dp[k-1][i][j+1][1],R+(k-1)*A[j+1]);
		}
	}
	for(int i=0;i<N;i++)cout<<ans[i]<<endl;
}
0