結果
問題 |
No.555 世界史のレポート
|
ユーザー |
|
提出日時 | 2017-08-11 22:37:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 598 bytes |
コンパイル時間 | 544 ms |
コンパイル使用メモリ | 55,752 KB |
最終ジャッジ日時 | 2025-01-05 02:11:26 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:10:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | int n, c, v; scanf("%d%d%d", &n, &c, &v); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <algorithm> #include <cstdio> #include <vector> #define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i)) using namespace std; template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); } constexpr int inf = 1e9+7; int main() { int n, c, v; scanf("%d%d%d", &n, &c, &v); vector<int> dp(2 * n + 1, inf); dp[1] = 0; repeat_from (x, 1, dp.size()) { for (int k = 1; x + k * x < dp.size(); ++ k) { setmin(dp[x + k * x], dp[x] + c + k * v); } } printf("%d\n", *min_element(dp.begin() + n, dp.end())); return 0; }