#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <time.h>
#include <map>
#include <algorithm>
#include<memory.h>
#include <limits.h>
#define MAX 0x0fffffff
using namespace std;
int G[101];
int k = 0;
int DP[5001];
void Init()
{
memset(G,0,sizeof(G));
memset(DP,0,sizeof(DP));
k = 0;
}
int main()
{
//freopen("D:\\input.txt","r",stdin);
int n,c1,c2;
while(cin>>n>>c1>>c2)
{
Init();
int total = 0;
for(int i=0;i<n;i++)
{
cin>>G[k];
total+=G[k];
k++;
}
for(int i=0;i<k;i++)
{
int w = G[i];
for(int j = c1;j>=w;j--)
{
DP[j] = max(DP[j],DP[j-w]+w);
}
}
if(total-DP[c1]<=c2)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
/**************************************************************
Problem: 1462
User: cust123
Language: C++
Result: Accepted
Time:10 ms
Memory:1540 kb
****************************************************************/
题目1462:两船载物问题
最新推荐文章于 2022-11-02 23:48:25 发布