結果

問題 No.798 コレクション
ユーザー BwambocosBwambocos
提出日時 2019-03-16 12:27:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 808 bytes
コンパイル時間 1,727 ms
コンパイル使用メモリ 178,676 KB
実行使用メモリ 34,572 KB
最終ジャッジ日時 2023-09-14 15:11:31
合計ジャッジ時間 3,396 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
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 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:16: 警告: 整数定数が大きすぎるので unsigned になりました
    7 | const LL inf = 11234567890123456789;
      |                ^~~~~~~~~~~~~~~~~~~~

ソースコード

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;

const LL inf = 11234567890123456789;
LL N;
std::vector<std::pair<LL, LL>>item;
std::vector<std::vector<LL>>memo;

LL dp(LL i, LL j)
{
	if (i == N)
	{
		if (j == N - N / 3) return 0;
		return inf;
	}
	if (memo[i][j] != -1) return memo[i][j];
	LL res1 = dp(i + 1, j), res2 = dp(i + 1, j + 1) + item[i].second + item[i].first*j;
	return memo[i][j] = std::min(res1, res2);
}

int main()
{
	in >> N;
	std::vector<LL>A(N), B(N);
	rep(i, N) in >> A[i] >> B[i];

	rep(i, N) item.push_back(std::make_pair(B[i], A[i]));
	std::sort(item.begin(), item.end(), std::greater<std::pair<LL, LL>>());
	memo.resize(N);
	rep(i, memo.size()) memo[i].resize(N, -1);
	out << dp(0, 0) << std::endl;
}
0