結果

問題 No.2390 Udon Coupon (Hard)
ユーザー x.t.x.t.
提出日時 2023-07-21 23:29:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 331 ms / 2,000 ms
コード長 1,088 bytes
コンパイル時間 1,565 ms
コンパイル使用メモリ 165,380 KB
実行使用メモリ 66,304 KB
最終ジャッジ日時 2024-04-15 21:05:26
合計ジャッジ時間 14,495 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
65,920 KB
testcase_01 AC 105 ms
66,304 KB
testcase_02 AC 317 ms
66,048 KB
testcase_03 AC 304 ms
66,176 KB
testcase_04 AC 319 ms
66,048 KB
testcase_05 AC 90 ms
66,176 KB
testcase_06 AC 313 ms
66,048 KB
testcase_07 AC 92 ms
65,920 KB
testcase_08 AC 93 ms
66,048 KB
testcase_09 AC 322 ms
66,176 KB
testcase_10 AC 97 ms
66,048 KB
testcase_11 AC 91 ms
66,176 KB
testcase_12 AC 96 ms
66,048 KB
testcase_13 AC 96 ms
65,920 KB
testcase_14 AC 102 ms
66,176 KB
testcase_15 AC 90 ms
66,176 KB
testcase_16 AC 97 ms
66,048 KB
testcase_17 AC 98 ms
66,176 KB
testcase_18 AC 101 ms
65,920 KB
testcase_19 AC 99 ms
66,048 KB
testcase_20 AC 97 ms
66,176 KB
testcase_21 AC 93 ms
65,920 KB
testcase_22 AC 316 ms
66,304 KB
testcase_23 AC 318 ms
66,048 KB
testcase_24 AC 321 ms
66,048 KB
testcase_25 AC 319 ms
66,176 KB
testcase_26 AC 323 ms
66,048 KB
testcase_27 AC 319 ms
66,176 KB
testcase_28 AC 318 ms
66,176 KB
testcase_29 AC 316 ms
66,048 KB
testcase_30 AC 315 ms
66,048 KB
testcase_31 AC 317 ms
66,176 KB
testcase_32 AC 315 ms
65,920 KB
testcase_33 AC 315 ms
66,048 KB
testcase_34 AC 310 ms
66,176 KB
testcase_35 AC 311 ms
66,048 KB
testcase_36 AC 314 ms
66,176 KB
testcase_37 AC 318 ms
65,920 KB
testcase_38 AC 324 ms
66,048 KB
testcase_39 AC 197 ms
66,176 KB
testcase_40 AC 317 ms
66,048 KB
testcase_41 AC 331 ms
66,048 KB
testcase_42 AC 319 ms
66,048 KB
testcase_43 AC 325 ms
66,048 KB
testcase_44 AC 318 ms
66,176 KB
testcase_45 AC 312 ms
65,920 KB
testcase_46 AC 315 ms
66,048 KB
testcase_47 AC 320 ms
66,048 KB
testcase_48 AC 323 ms
65,920 KB
testcase_49 AC 93 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