結果

問題 No.2386 Udon Coupon (Easy)
ユーザー HIcoderHIcoder
提出日時 2023-07-21 21:58:11
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 641 bytes
コンパイル時間 682 ms
コンパイル使用メモリ 85,108 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-21 23:29:25
合計ジャッジ時間 1,705 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<tuple>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;


int main(){
    int N;
    cin>>N;
    ll A,B,C;
    cin>>A>>B>>C;

    vector<ll> dp(N+1,-INF);
    dp[0]=0;

    for(int i=0;i<=N;i++){
        if(i+3<=N){
            dp[i+3]=max(dp[i]+A,dp[i+3]);
        }
        if(i+5<=N){
            dp[i+5]=max(dp[i]+B,dp[i+5]);   
        }
        if(i+10<=N){
            dp[i+10]=max(dp[i]+C,dp[i+10]);   
        }
    }
    ll D=0;
    for(int i=0;i<=N;i++){
        D=max(D,dp[i]);
    }
    cout<<D<<endl;
}
0