結果
問題 | No.2386 Udon Coupon (Easy) |
ユーザー |
|
提出日時 | 2023-12-31 12:28:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 658 bytes |
コンパイル時間 | 1,458 ms |
コンパイル使用メモリ | 166,972 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-27 17:04:37 |
合計ジャッジ時間 | 2,878 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define ll long long #define all(x) x.begin(),x.end() #define rep(i,a,b) for(int i=a;i<=b;i++) #define each(a,x) for (auto& x: a) const char nl = '\n'; int dp[200005]; void solve(){ int n; cin >> n; int a,b,c; cin >> a >> b >> c; rep(i,3,n) { dp[i] = dp[i-1]; if (i >= 3) dp[i] = max(dp[i], dp[i-3] + a); if (i >= 5) dp[i] = max(dp[i], dp[i-5] + b); if (i >= 10) dp[i] = max(dp[i], dp[i-10] + c); } cout << dp[n] << nl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1;// cin >> t; while (t--){ solve(); } }