結果

問題 No.818 Dinner time
ユーザー BwambocosBwambocos
提出日時 2019-04-19 22:29:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 900 bytes
コンパイル時間 1,845 ms
コンパイル使用メモリ 177,440 KB
実行使用メモリ 21,664 KB
最終ジャッジ日時 2023-10-24 05:05:05
合計ジャッジ時間 6,099 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,696 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 WA -
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'LL dp(LL, LL)':
main.cpp:31:1: warning: control reaches end of non-void function [-Wreturn-type]
   31 | }
      | ^

ソースコード

diff #

#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

LL N, M;
std::vector<LL>A, B;
std::vector<std::vector<LL>>memo;

LL dp(LL i, LL j)
{
	if (i == -1) return 0;
	if (j == 0)
	{
		LL res1 = dp(i - 1, 0);
		LL res2 = dp(i - 1, 1) + std::max(A[i], B[i]);
		LL res3 = dp(i - 1, 2) + A[i] * (M - 1) + std::max(A[i], B[i]);
		return memo[i][j] = std::max({ res1,res2,res3 });
	}
	if (j == 1)
	{
		LL res1 = dp(i - 1, 1) + std::max(A[i], B[i]);
		LL res2 = dp(i - 1, 2) + A[i] * (M - 1) + std::max(A[i], B[i]);
		return memo[i][j] = std::max({ res1,res2 });
	}
	if (j == 2)
	{
		return memo[i][j] = dp(i - 1, 2) + A[i] * (M - 1) + std::max(A[i], B[i]);
	}
}

int main()
{
	in >> N >> M;
	A.resize(N); B.resize(N);
	rep(i, N) in >> A[i] >> B[i];

	memo.resize(N + 1, std::vector<LL>(5, -1));
	out << dp(N - 1, 0) << std::endl;
}
0