結果

問題 No.555 世界史のレポート
ユーザー ats5515ats5515
提出日時 2017-08-11 23:01:57
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 934 bytes
コンパイル時間 692 ms
コンパイル使用メモリ 69,224 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-20 23:20:08
合計ジャッジ時間 1,471 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 9 ms
9,344 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
#define int long long

signed main() {
	int N;
	int c, v;
	cin >> N;
	cin >> c >> v;
	vector<vector<int> > dp(20);
	for (int j = 0; j < 20; j++) {
		dp[j].resize(N, 10000000000);
	}
	dp[1][1] = 0;
	int res = 10000000000;
	int t;
	for (int i = 1; i < N; i++) {
		for (int j = 1; j < 20; j++) {
			if (j < 19) {
				t = i + (1 << (j - 1));
				if (t < N) {
					dp[j + 1][t] = min(dp[j + 1][t], dp[j][i] + c + v);
				}
				else {
					res = min(res, dp[j][i] + c + v);
				}
				
			}
			if (j > 1) {
				t = i + (1 << (j - 2));
				if (t < N) {
					dp[j][t] = min(dp[j][t], dp[j][i] + v);
				}
				else {
					res = min(res, dp[j][i]  + v);
				}
			}
		}
	}
	/*
	for (int i = 1; i < N; i++) {
		for (int j = 1; j < 5; j++) {
			cerr << dp[j][i] << " ";
		}
		cerr << endl;
	}
	*/
	cout << res << endl;
	return 0;
}
0