现在的位置: 首页 > 综合 > 正文

【bzoj 1222】: [HNOI2001]产品加工

2017年04月28日 ⁄ 综合 ⁄ 共 1501字 ⁄ 字号 评论关闭

http://www.lydsy.com/JudgeOnline/problem.php?id=1222

好像在哪见过~~~~

//#define _TEST _TEST
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
/************************************************
Code By willinglive
************************************************/
/////////////////////////////////////////////////
const int inf=300000;
#define rep(i,l,r) for(int i=l,___t=(r);i<=___t;i++)
#define per(i,r,l) for(int i=r,___t=(l);i>=___t;i--)
#define MS(arr,x) memset(arr,x,sizeof(arr))
#define LL long long
#define INE(i,u,e) for(int i=head[u];~i;i=e[i].next)
inline const LL getint()
{
    LL r=0,k=1;char c=getchar();
    for(;c<'0'||c>'9';c=getchar())if(c=='-')k=-1;
    for(;c>='0'&&c<='9';c=getchar())r=r*10+c-'0';
    return k*r;
}
/////////////////////////////////////////////////
int mmax;
int n;
int dat[6010][3];
int dp[30001];
/////////////////////////////////////////////////

/////////////////////////////////////////////////
void input()
{
	n=getint();
	int tmp;
	rep(i,1,n)
	{
		tmp=inf;
		rep(j,0,2)
		{
			dat[i][j]=getint();
			if(!dat[i][j]) dat[i][j]=inf;
			if(dat[i][j]<tmp) tmp=dat[i][j];
		}
		mmax+=tmp;
	}
}
void solve()
{
	rep(i,1,n)
	{
		per(j,mmax,0)
		{
			int tmp=inf;
			if(j-dat[i][0]>=0)
			    tmp=min(tmp,dp[j-dat[i][0]]);
            tmp=min(tmp,dp[j]+dat[i][1]);
            if(j-dat[i][2]>=0)
			    tmp=min(tmp,dp[j-dat[i][2]]+dat[i][2]);
            dp[j]=tmp;
		}
	}
	int ans=inf;
	rep(i,0,mmax) ans=min(ans,max(dp[i],i));
	printf("%d\n",ans);
}
/////////////////////////////////////////////////
int main()
{
    #ifndef _TEST
    freopen("std.in","r",stdin); freopen("std.out","w",stdout);
    #endif
    input();
    solve();
    return 0;
}

抱歉!评论已关闭.