結果

問題 No.2390 Udon Coupon (Hard)
ユーザー 👑 tatyamtatyam
提出日時 2023-07-17 20:25:44
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 692 bytes
コンパイル時間 4,121 ms
コンパイル使用メモリ 253,504 KB
実行使用メモリ 65,788 KB
最終ジャッジ日時 2023-10-18 00:36:58
合計ジャッジ時間 9,647 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
65,780 KB
testcase_01 AC 60 ms
65,780 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 59 ms
65,780 KB
testcase_06 WA -
testcase_07 AC 59 ms
65,780 KB
testcase_08 AC 59 ms
65,780 KB
testcase_09 WA -
testcase_10 AC 58 ms
65,780 KB
testcase_11 AC 54 ms
65,780 KB
testcase_12 AC 60 ms
65,780 KB
testcase_13 AC 54 ms
65,780 KB
testcase_14 AC 54 ms
65,780 KB
testcase_15 AC 54 ms
65,780 KB
testcase_16 AC 54 ms
65,780 KB
testcase_17 AC 60 ms
65,780 KB
testcase_18 AC 60 ms
65,780 KB
testcase_19 AC 62 ms
65,780 KB
testcase_20 AC 59 ms
65,780 KB
testcase_21 AC 59 ms
65,780 KB
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 59 ms
65,780 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 60 ms
65,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
void chmax(i64& a, i64 b) {if(a < b) a = b; }


i64 solve() {
    i64 N;
    cin >> N;
    vector<pair<i64, i64>> A(3);
    for(auto& [a, b] : A) cin >> a >> b;
    sort(A.begin(), A.end(), [&](pair<i64, i64> a, pair<i64, i64> b) { return a.first * b.second > a.second * b.first; });
    
    const i64 MX = 8e6;
    vector<i64> dp(MX + 1);
    for(i64 i = 0; i < MX; i++) for(auto [a, b] : A) if(i + a <= MX) chmax(dp[i + a], dp[i] + b);
    if(N <= MX) return dp[N];
    const auto [a, b] = A[0];
    for(i64 i = MX; ; i--) if((N - i) % a == 0) return dp[i] + (N - i) / a * b;
}
int main() {
    cout << solve() << endl;
}
0