結果
| 問題 | 
                            No.2701 A cans -> B cans
                             | 
                    
| コンテスト | |
| ユーザー | 
                             inksamurai
                         | 
                    
| 提出日時 | 2024-03-29 23:13:44 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 80 ms / 1,000 ms | 
| コード長 | 1,152 bytes | 
| コンパイル時間 | 1,921 ms | 
| コンパイル使用メモリ | 197,348 KB | 
| 最終ジャッジ日時 | 2025-02-20 15:31:38 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 6 | 
| other | AC * 73 | 
ソースコード
#include <bits/stdc++.h>
#define int ll
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) ((int) a.size())
#define vec(...) vector<__VA_ARGS__>
#define _4ab8goq ios::sync_with_stdio(0),cin.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}
void slv(){
	int n,m;
	cin>>n>>m;
	vec(array<int,3>) a(n);
	rep(i,n){
		rep(j,3){
			cin>>a[i][j];
		}
	}
	vi dp(m+1);
	per(i,n){
		vi ndp(m+1);
		vi fdp(m+1);
		rep(j,m+1){
			fdp[j]=max(fdp[j],dp[j]);
			int d=a[i][0]-a[i][1];
			if(j-d>=0){
				fdp[j]=max(fdp[j],fdp[j-d]+a[i][2]*a[i][1]);
			}
			ndp[j]=max(ndp[j],dp[j]);
			if(j-a[i][0]>=0){
				// if(!i and j==5){
				// 	print(fdp[j-a[i][0]]);
				// }
				ndp[j]=max(ndp[j],fdp[j-a[i][0]]+a[i][2]*a[i][1]);
			}
		}
		dp.swap(ndp);
	}
	rng(i,1,m+1){
		cout<<dp[i]<<"\n";
	}
}
signed main(){
_4ab8goq;
	slv();
}
            
            
            
        
            
inksamurai