其他分享
首页 > 其他分享> > P2925 [USACO08DEC]Hay For Sale S 题解

P2925 [USACO08DEC]Hay For Sale S 题解

作者:互联网

P2925 [USACO08DEC]Hay For Sale S

#include<iostream>
using namespace std;
long long dp[50001];
int h[5001];
int main()
{
	int C,H;
	cin>>C>>H;
	for (int i=1;i<=H;i++)
	{
		cin>>h[i];
	}
	for (int i=1;i<=H;i++)
	{
		for (int j=C;j>=h[i];j--)
		{
			dp[j]=max(dp[j],dp[j-h[i]]+h[i]);
		}
	}
	cout<<dp[C]<<endl;
 } 

  

标签:int,题解,Sale,long,Hay,USACO08DEC,P2925,dp
来源: https://www.cnblogs.com/smghj/p/16033160.html