結果

問題 No.2390 Udon Coupon (Hard)
ユーザー achapiachapi
提出日時 2023-07-21 23:04:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 541 bytes
コンパイル時間 4,106 ms
コンパイル使用メモリ 204,808 KB
実行使用メモリ 32,944 KB
最終ジャッジ日時 2023-10-21 23:06:10
合計ジャッジ時間 5,107 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 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 19 ms
14,020 KB
testcase_40 AC 16 ms
10,064 KB
testcase_41 AC 21 ms
11,580 KB
testcase_42 AC 13 ms
9,800 KB
testcase_43 AC 18 ms
13,888 KB
testcase_44 AC 11 ms
10,724 KB
testcase_45 AC 14 ms
8,416 KB
testcase_46 AC 4 ms
4,444 KB
testcase_47 AC 8 ms
8,548 KB
testcase_48 AC 12 ms
7,096 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<int> A(3), B(3);
	for (int i = 0; i < 3; i++){
		cin >> A[i] >> B[i];
	}
	auto f = [&](int x, int y) -> long long {
		int 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