卬高杯
提出id | 提出時刻 | ユーザー名 | 問題 | 言語 | 判定状況 | 判定 | 実行時間 |
---|---|---|---|---|---|---|---|
114752 | 2023-10-24 07:39:08 | n_o_n_o_n | G | cpp | 16/16 | AC | 52 |
#include<bits/stdc++.h>
using namespace std;
void chmax(int &a, int b)
{
if(a<b)a=b;
return;
}
int N,M,X[20001],Y[20001],dp[20001][101];
int main(){
cin>>N>>M;
for(int i=1; i<=N; i++)cin>>X[i];
for(int i=1; i<=N; i++)cin>>Y[i];
for(int i=1; i<=N; i++)
{
for(int j=0; j<M; j++)
{
chmax(dp[i][j],dp[i-1][j]);
if(j>=Y[i])chmax(dp[i][j],dp[i-1][j-Y[i]]+X[i]);
}
}
int ans=0;
for(int j=0; j<M; j++)chmax(ans,dp[N][j]);
cout << ans << endl;
}
sample1.txt AC 2 case1.txt AC 2 case2.txt AC 41 case3.txt AC 2 case4.txt AC 11 case5.txt AC 17 case6.txt AC 21 case7.txt AC 24 case8.txt AC 17 case9.txt AC 8 case10.txt AC 52 case11.txt AC 13 case12.txt AC 12 case13.txt AC 22 case14.txt AC 47 case15.txt AC 3 52 AC52 AC