結果

問題 No.2701 A cans -> B cans
ユーザー GOTKAKOGOTKAKO
提出日時 2024-03-29 21:53:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 719 ms / 1,000 ms
コード長 2,246 bytes
コンパイル時間 2,199 ms
コンパイル使用メモリ 199,924 KB
実行使用メモリ 198,912 KB
最終ジャッジ日時 2024-04-20 12:15:05
合計ジャッジ時間 14,731 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 36 ms
5,376 KB
testcase_07 AC 37 ms
5,376 KB
testcase_08 AC 37 ms
5,376 KB
testcase_09 AC 37 ms
5,376 KB
testcase_10 AC 37 ms
5,376 KB
testcase_11 AC 37 ms
5,376 KB
testcase_12 AC 37 ms
5,376 KB
testcase_13 AC 37 ms
5,376 KB
testcase_14 AC 36 ms
5,376 KB
testcase_15 AC 37 ms
5,376 KB
testcase_16 AC 37 ms
5,376 KB
testcase_17 AC 37 ms
5,376 KB
testcase_18 AC 37 ms
5,376 KB
testcase_19 AC 37 ms
5,376 KB
testcase_20 AC 37 ms
5,376 KB
testcase_21 AC 37 ms
5,376 KB
testcase_22 AC 37 ms
5,376 KB
testcase_23 AC 40 ms
5,376 KB
testcase_24 AC 37 ms
5,376 KB
testcase_25 AC 38 ms
5,376 KB
testcase_26 AC 666 ms
198,912 KB
testcase_27 AC 658 ms
198,784 KB
testcase_28 AC 681 ms
198,656 KB
testcase_29 AC 674 ms
198,784 KB
testcase_30 AC 670 ms
198,784 KB
testcase_31 AC 668 ms
198,784 KB
testcase_32 AC 665 ms
198,912 KB
testcase_33 AC 665 ms
198,784 KB
testcase_34 AC 666 ms
198,912 KB
testcase_35 AC 667 ms
198,784 KB
testcase_36 AC 659 ms
198,656 KB
testcase_37 AC 664 ms
198,784 KB
testcase_38 AC 663 ms
198,784 KB
testcase_39 AC 653 ms
198,784 KB
testcase_40 AC 661 ms
198,912 KB
testcase_41 AC 664 ms
198,912 KB
testcase_42 AC 669 ms
198,912 KB
testcase_43 AC 660 ms
198,784 KB
testcase_44 AC 667 ms
198,912 KB
testcase_45 AC 668 ms
198,912 KB
testcase_46 AC 667 ms
198,912 KB
testcase_47 AC 666 ms
198,912 KB
testcase_48 AC 675 ms
198,784 KB
testcase_49 AC 674 ms
198,656 KB
testcase_50 AC 678 ms
198,912 KB
testcase_51 AC 665 ms
198,912 KB
testcase_52 AC 660 ms
198,912 KB
testcase_53 AC 669 ms
198,912 KB
testcase_54 AC 679 ms
198,912 KB
testcase_55 AC 672 ms
198,784 KB
testcase_56 AC 671 ms
198,784 KB
testcase_57 AC 661 ms
198,912 KB
testcase_58 AC 667 ms
198,784 KB
testcase_59 AC 38 ms
5,376 KB
testcase_60 AC 38 ms
5,376 KB
testcase_61 AC 38 ms
5,376 KB
testcase_62 AC 38 ms
5,376 KB
testcase_63 AC 38 ms
5,376 KB
testcase_64 AC 38 ms
5,376 KB
testcase_65 AC 37 ms
5,376 KB
testcase_66 AC 38 ms
5,376 KB
testcase_67 AC 39 ms
5,376 KB
testcase_68 AC 39 ms
5,376 KB
testcase_69 AC 688 ms
198,912 KB
testcase_70 AC 691 ms
198,784 KB
testcase_71 AC 697 ms
198,656 KB
testcase_72 AC 679 ms
198,656 KB
testcase_73 AC 694 ms
198,912 KB
testcase_74 AC 679 ms
198,784 KB
testcase_75 AC 678 ms
198,912 KB
testcase_76 AC 681 ms
198,912 KB
testcase_77 AC 719 ms
198,784 KB
testcase_78 AC 687 ms
198,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

long long mod = 998244353;
//入力が必ずmod未満の時に使う.
struct mint{
    long long v = 0;
    mint(){} mint(int a){v = a;} mint(long long a){v = a;} mint(unsigned long long a){v = a;}
    long long val(){return v;}
    void modu(){v %= mod;}
 
    mint repeat2mint(long long a,long long b){
        mint ret = 1,p = a;
        while(b){if(b&1) ret *= p; p *= p; b >>= 1;}
        return ret;
    };
 
    mint operator+(mint b){return (v+b.v)%mod;}
    mint operator-(mint b){return (v-b.v+mod)%mod;}
    mint operator*(mint b){return v*b.v%mod;}
    mint operator/(mint b){
        if(b.v == 0) assert(false);
        return v*(repeat2mint(b.v,mod-2)).v%mod;
    }
 
    void operator+=(mint b){v = (v+b.v)%mod;}
    void operator-=(mint b){v = (v-b.v+mod)%mod;}
    void operator*=(mint b){v = v*b.v%mod;}
    void operator/=(mint b){
    if(b.v == 0) assert(false);
        v = v*repeat2mint(b.v,mod-2).v%mod;
    }
 
    void operator++(int){v = (v+1)%mod; return;}
    void operator--(int){v = (v-1+mod)%mod; return;}
    bool operator==(mint b){if(v == b.v) return true; else return false;}
    bool operator!=(mint b){if(v != b.v) return true; else return false;}
    bool operator>(mint b){if(v > b.v) return true; else return false;}
    bool operator>=(mint b){if(v >= b.v) return true; else return false;}
    bool operator<(mint b){if(v < b.v) return true; else return false;}
    bool operator<=(mint b){if(v <= b.v) return true; else return false;}
 
    mint pow(long long x){return repeat2mint(v,x);}
    mint inv(){return mint(1)/v;}
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N,M; cin >> N >> M;
    vector<vector<long long>> C(N,vector<long long>(M+1));
    for(int i=0; i<N; i++){
        long long a,b,c; cin >> a >> b >> c;
        c *= b; b = a-b;
        long long now = 0;
        for(int k=a; k<=M; k+=b) now += c,C.at(i).at(k) = now;
    }
    
    vector<long long> dp(M+1);
    for(int i=0; i<=M; i++){
        for(int k=0; k<N; k++) dp.at(i) = max(dp.at(i),C.at(k).at(i));
        for(int k=1; k<i; k++) dp.at(i) = max(dp.at(i),dp.at(k)+dp.at(i-k));
    }

    for(int i=1; i<=M; i++) cout << dp.at(i) << endl;
}
0