結果
問題 | No.2386 Udon Coupon (Easy) |
ユーザー |
![]() |
提出日時 | 2024-02-11 00:38:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 720 bytes |
コンパイル時間 | 1,804 ms |
コンパイル使用メモリ | 192,812 KB |
最終ジャッジ日時 | 2025-02-19 04:49:04 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #define _GLIBCXX_DEBUG #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n, a, b, c; cin >> n >> a >> b >> c; vector<int> memo(n + 1, -1); auto dfs = [&](auto &&self, int x) -> int { if (x == 0) return 0; if (memo[x] != -1) return memo[x]; int res = 0; if (x >= 3) res = max(res, self(self, x - 3) + a); if (x >= 5) res = max(res, self(self, x - 5) + b); if (x >= 10) res = max(res, self(self, x - 10) + c); return memo[x] = res; }; cout << dfs(dfs, n) << endl; return 0; }