結果
| 問題 |
No.2386 Udon Coupon (Easy)
|
| コンテスト | |
| ユーザー |
eve__fuyuki
|
| 提出日時 | 2023-07-31 10:11:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 679 bytes |
| コンパイル時間 | 1,889 ms |
| コンパイル使用メモリ | 196,752 KB |
| 最終ジャッジ日時 | 2025-02-15 21:09:29 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
void fast_io() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
}
int main() {
fast_io();
int n;
cin >> n;
int a[3];
cin >> a[0] >> a[1] >> a[2];
int need[3] = {3, 5, 10};
vector<vector<int>> dp(4, vector<int>(n + 1));
for (int i = 0; i < 3; i++) {
for (int j = 0; j <= n; j++) {
dp[i + 1][j] = dp[i][j];
if (j >= need[i]) {
dp[i + 1][j] = max(dp[i + 1][j], dp[i + 1][j - need[i]] + a[i]);
}
}
}
int ans = 0;
for (int i = 0; i <= n; i++) {
ans = max(ans, dp[3][i]);
}
cout << ans << endl;
}
eve__fuyuki