結果

問題 No.2390 Udon Coupon (Hard)
ユーザー achapiachapi
提出日時 2023-07-21 23:17:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 553 bytes
コンパイル時間 2,153 ms
コンパイル使用メモリ 204,284 KB
実行使用メモリ 32,972 KB
最終ジャッジ日時 2023-10-21 23:18:05
合計ジャッジ時間 5,132 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 35 ms
14,048 KB
testcase_40 AC 30 ms
10,092 KB
testcase_41 AC 39 ms
11,608 KB
testcase_42 AC 23 ms
9,828 KB
testcase_43 AC 31 ms
13,916 KB
testcase_44 AC 19 ms
10,752 KB
testcase_45 AC 24 ms
8,444 KB
testcase_46 AC 6 ms
4,464 KB
testcase_47 AC 13 ms
8,576 KB
testcase_48 AC 21 ms
7,124 KB
testcase_49 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	long long N;
	cin >> N;
	vector<long long> A(3), B(3);
	for (int i = 0; i < 3; i++){
		cin >> A[i] >> B[i];
	}
	auto f = [&](int x, int y) -> long long {
		long long l = lcm(A[x], A[y]);
		vector<long long> dp(l + 1);
		for (int i = 0; i <= l; i++){
			for (int j = 0; j < 3; j++){
				if (i + A[j] <= l){
					dp[i + A[j]] = max(dp[i + A[j]], dp[i] + B[j]);
				}
			}
		}
		return dp[l] * (N / l) + dp[(N % l)];
	};
	long long ans = max({f(0, 1), f(0, 2), f(1, 2)});
	cout << ans << '\n';
}
0