結果

問題 No.2390 Udon Coupon (Hard)
ユーザー ripityripity
提出日時 2023-07-21 22:07:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 2,400 ms
コンパイル使用メモリ 196,224 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-04-15 21:00:24
合計ジャッジ時間 4,610 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
11,456 KB
testcase_01 AC 11 ms
11,392 KB
testcase_02 AC 22 ms
11,448 KB
testcase_03 AC 22 ms
11,428 KB
testcase_04 AC 22 ms
11,380 KB
testcase_05 AC 9 ms
11,392 KB
testcase_06 AC 22 ms
11,520 KB
testcase_07 AC 10 ms
11,392 KB
testcase_08 AC 10 ms
11,392 KB
testcase_09 AC 21 ms
11,520 KB
testcase_10 AC 11 ms
11,392 KB
testcase_11 AC 10 ms
11,520 KB
testcase_12 AC 13 ms
11,264 KB
testcase_13 AC 10 ms
11,392 KB
testcase_14 AC 11 ms
11,520 KB
testcase_15 AC 10 ms
11,520 KB
testcase_16 AC 11 ms
11,448 KB
testcase_17 AC 10 ms
11,392 KB
testcase_18 AC 10 ms
11,392 KB
testcase_19 AC 11 ms
11,476 KB
testcase_20 AC 10 ms
11,392 KB
testcase_21 AC 9 ms
11,392 KB
testcase_22 AC 22 ms
11,520 KB
testcase_23 AC 22 ms
11,520 KB
testcase_24 AC 21 ms
11,392 KB
testcase_25 AC 23 ms
11,368 KB
testcase_26 AC 22 ms
11,392 KB
testcase_27 AC 21 ms
11,388 KB
testcase_28 AC 22 ms
11,392 KB
testcase_29 AC 21 ms
11,520 KB
testcase_30 AC 24 ms
11,372 KB
testcase_31 AC 22 ms
11,520 KB
testcase_32 AC 21 ms
11,476 KB
testcase_33 AC 22 ms
11,388 KB
testcase_34 AC 21 ms
11,264 KB
testcase_35 AC 21 ms
11,392 KB
testcase_36 AC 22 ms
11,380 KB
testcase_37 AC 22 ms
11,512 KB
testcase_38 AC 21 ms
11,520 KB
testcase_39 AC 21 ms
11,520 KB
testcase_40 AC 22 ms
11,512 KB
testcase_41 AC 22 ms
11,464 KB
testcase_42 AC 21 ms
11,392 KB
testcase_43 AC 21 ms
11,392 KB
testcase_44 AC 22 ms
11,392 KB
testcase_45 AC 21 ms
11,392 KB
testcase_46 AC 22 ms
11,392 KB
testcase_47 AC 21 ms
11,440 KB
testcase_48 AC 22 ms
11,376 KB
testcase_49 AC 10 ms
11,520 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];
	}
	for( int i = 0; i < 3-1; i++ ) {
		for( int j = i+1; j < 3; j++ ) {
			if( A[i]*B[j] > A[j]*B[i] ) {
				swap(A[i], A[j]);
				swap(B[i], B[j]);
			}
		}
	}
	int K = 1<<20;
	long long ans = 0;
	vector<long long> dp(K);
	for( int i = 0; i < K; i++ ) {
		for( int j = 0; j < 3; j++ ) {
			if( i >= A[j] ) dp[i] = max(dp[i], dp[i-A[j]]+B[j]);
		}
		if( i <= N ) ans = max(ans, dp[i]+B[0]*((N-i)/A[0]));
	}
	cout << ans << endl;
}
0