hdu 4314 Save the dwarfs
来源:互联网 发布:http请求json数据 编辑:程序博客网 时间:2024/06/05 14:23
又是一个i写成j了,找了好久才发现
#include<iostream>#include<vector>#include<algorithm>#include<cstdio>#include<queue>#include<stack>#include<string>#include<map>#include<set>#include<cmath>#include<cassert>#include<cstring>#include<iomanip>using namespace std;#ifdef _WIN32#define i64 __int64#define out64 "%I64d\n"#define in64 "%I64d"#else#define i64 long long#define out64 "%lld\n"#define in64 "%lld"#endif/************ for topcoder by zz1215 *******************/#define FOR(i,a,b) for( int i = (a) ; i <= (b) ; i ++)#define FFF(i,a) for( int i = 0 ; i < (a) ; i ++)#define FFD(i,a,b) for( int i = (a) ; i >= (b) ; i --)#define S64(a) scanf(in64,&a)#define SS(a) scanf("%d",&a)#define LL(a) ((a)<<1)#define RR(a) (((a)<<1)+1)#define pb push_back#define CL(Q) while(!Q.empty())Q.pop()#define MM(name,what) memset(name,what,sizeof(name))#define read freopen("in.txt","r",stdin)#define write freopen("out.txt","w",stdout)const int inf = 0x3f3f3f3f;const i64 inf64 = 0x3f3f3f3f3f3f3f3fLL;const double oo = 10e9;const double eps = 10e-9;const double pi = acos(-1.0);const int maxn = 2011;struct zz{int x;int y;bool operator < (const zz & cmp) const{return x+y<cmp.x+cmp.y;}}zx;int dp[maxn][maxn];int f[maxn];int n,h;vector<zz>v;int start(){for(int i=0;i<=n;i++){dp[i][0]=0;}int temp;for(int i=1;i<=n;i++){for(int j=1;j<=i;j++){temp = v[i].x+v[i].y;dp[i][j]=min(max(dp[i-1][j-1],h-f[i-1]-temp),max(dp[i-1][j]-v[i].x,0));}}int ans=0;for(int i=1;i<=n;i++){if(!dp[n][i]){ans=i;}}return ans;}int main(){while(cin>>n){v.clear();for(int i=0;i<=n;i++){for(int j=0;j<=n;j++){dp[i][j]=inf;}}MM(f,0);for(int i=1;i<=n;i++){cin>>zx.x>>zx.y;v.pb(zx);}cin>>h;zx.x=zx.y=inf;v.pb(zx);sort(v.begin(),v.end());reverse(v.begin(),v.end());for(int i=1;i<=n;i++){f[i]=f[i-1]+v[i].x;}cout<<start()<<endl;} return 0;}
- hdu Save the dwarfs 4314
- hdu 4314 Save the dwarfs
- HDU-4314-Save the dwarfs
- hdu - 4314 - Save the dwarfs - dp
- hdu 4314 Save the dwarfs(dp,4级,多校)
- HDU 4315 Save the dwarfs 动态规划
- Save the dwarfs
- HDU4314-Save the dwarfs
- MUTC 2 E - Save the dwarfs DP?
- hdu4314Save the dwarfs【dp】
- hdu4314Save the dwarfs 【dp】
- Snow White and the Seven Dwarfs
- URAL 1243. Divorce of the Seven Dwarfs
- URAL 1243 Divorce of the Seven Dwarfs
- Hdu 2284 Solve the puzzle, Save the world! (组合数)
- POJ 1912 A highway and the seven dwarfs 已翻译
- poj1912:A highway and the seven dwarfs(凸包)
- poj1912 A highway and the seven dwarfs【凸包+二分】
- git工具用法 && git管理googlecode
- ubuntu 12安装xen
- linq学习(from)
- [linux常用命令] 2、强大的搜索指令grep
- MongoDB集成Hadoop进行统计计算
- hdu 4314 Save the dwarfs
- 二.redis 数据类型
- 设计模式(1):单例模式
- Oracle unable to extend table in tablespace
- Winform中Control.KeyDown 事件(整理自MSDN)
- cmd一些命令详解
- SQL 语句修改字段名称
- 学习PHP面向对象(二)构造方法与析构方法
- Java如何将两个数组的元素按顺序合并