結果
問題 |
No.555 世界史のレポート
|
ユーザー |
![]() |
提出日時 | 2017-08-11 22:56:42 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 929 bytes |
コンパイル時間 | 644 ms |
コンパイル使用メモリ | 69,348 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-10-12 21:38:16 |
合計ジャッジ時間 | 1,451 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 WA * 14 |
ソースコード
#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, 10000000); } dp[1][1] = 0; int res = 100000000; 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; }