結果

問題 No.2390 Udon Coupon (Hard)
ユーザー RubikunRubikun
提出日時 2023-07-21 21:36:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 336 ms / 2,000 ms
コード長 1,089 bytes
コンパイル時間 2,233 ms
コンパイル使用メモリ 196,560 KB
実行使用メモリ 66,176 KB
最終ジャッジ日時 2024-04-15 20:58:27
合計ジャッジ時間 15,382 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
66,176 KB
testcase_01 AC 105 ms
65,920 KB
testcase_02 AC 315 ms
66,176 KB
testcase_03 AC 314 ms
66,048 KB
testcase_04 AC 319 ms
66,048 KB
testcase_05 AC 89 ms
66,048 KB
testcase_06 AC 320 ms
65,920 KB
testcase_07 AC 90 ms
66,176 KB
testcase_08 AC 92 ms
66,048 KB
testcase_09 AC 318 ms
66,048 KB
testcase_10 AC 94 ms
66,048 KB
testcase_11 AC 90 ms
65,920 KB
testcase_12 AC 96 ms
66,048 KB
testcase_13 AC 95 ms
66,048 KB
testcase_14 AC 102 ms
66,048 KB
testcase_15 AC 88 ms
66,048 KB
testcase_16 AC 98 ms
66,048 KB
testcase_17 AC 93 ms
66,048 KB
testcase_18 AC 99 ms
66,048 KB
testcase_19 AC 95 ms
65,792 KB
testcase_20 AC 92 ms
65,920 KB
testcase_21 AC 95 ms
65,920 KB
testcase_22 AC 319 ms
66,176 KB
testcase_23 AC 318 ms
66,048 KB
testcase_24 AC 314 ms
66,176 KB
testcase_25 AC 323 ms
66,176 KB
testcase_26 AC 313 ms
66,048 KB
testcase_27 AC 312 ms
65,920 KB
testcase_28 AC 314 ms
66,048 KB
testcase_29 AC 317 ms
66,048 KB
testcase_30 AC 323 ms
66,176 KB
testcase_31 AC 317 ms
66,048 KB
testcase_32 AC 321 ms
66,048 KB
testcase_33 AC 319 ms
66,048 KB
testcase_34 AC 317 ms
66,048 KB
testcase_35 AC 314 ms
66,048 KB
testcase_36 AC 335 ms
65,920 KB
testcase_37 AC 336 ms
66,048 KB
testcase_38 AC 323 ms
66,176 KB
testcase_39 AC 203 ms
66,048 KB
testcase_40 AC 318 ms
65,920 KB
testcase_41 AC 335 ms
66,048 KB
testcase_42 AC 320 ms
66,048 KB
testcase_43 AC 328 ms
65,920 KB
testcase_44 AC 314 ms
65,792 KB
testcase_45 AC 311 ms
66,048 KB
testcase_46 AC 313 ms
66,048 KB
testcase_47 AC 310 ms
66,176 KB
testcase_48 AC 317 ms
66,176 KB
testcase_49 AC 90 ms
66,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=8000005;
const ll INF=1LL<<60;

ll dp[MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;cin>>N;
    for(int i=0;i<MAX;i++) dp[i]=-INF;
    dp[0]=0;
    
    vector<ll> A(3),B(3);
    for(int i=0;i<3;i++) cin>>A[i]>>B[i];
    for(int i=1;i<MAX;i++){
        for(int j=0;j<3;j++){
            if(i-A[j]>=0) chmax(dp[i],dp[i-A[j]]+B[j]);
        }
    }
    
    ll ans=0;
    
    for(int i=0;i<MAX;i++){
        for(int j=0;j<3;j++){
            ll rem=N-i;
            if(rem<0) continue;
            chmax(ans,dp[i]+(rem/A[j])*B[j]);
        }
    }
    
    cout<<ans<<endl;
}
0