HDU 3433 A Task Process

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1368    Accepted Submission(s):
684

Problem Description
There are two kinds of tasks, namely A and B. There are
N workers and the i-th worker would like to finish one task A in ai minutes, one
task B in bi minutes. Now you have X task A and Y task B, you want to assign
each worker some tasks and finish all the tasks as soon as possible. You should
note that the workers are working simultaneously.
 
Input
In the first line there is an integer T(T<=50),
indicates the number of test cases.

In each case, the first line contains
three integers N(1<=N<=50), X,Y(1<=X,Y<=200). Then there are N
lines, each line contain two integers ai, bi (1<=ai, bi <=1000).

 
Output
For each test case, output “Case d: “ at first line
where d is the case number counted from one, then output the shortest time to
finish all the tasks.
 
Sample Input
3
2 2 2
1 10
10 1
2 2 2
1 1
10 10
3 3 3
2 7
5 5
7 2
Sample Output
Case 1: 2
Case 2: 4
Case 3: 6
  1. /*
  2. 二分+DP。
  3. 二分时间t,dp[i][j]表示在时间t内前i个人完成j件A任务所能完成的B任务的最大数量。如果dp[i][x]>=y
  4. 就是可以的。然后不断迭代得到ans。
  5. */
  6. #include<iostream>
  7. using namespace std;
  8. #include<cstdio>
  9. #include<cstring>
  10. #define N 70
  11. int T,n,x,y,a[N],b[N];
  12. void input(int &r)
  13. {
  14. memset(a,,sizeof(a));
  15. memset(b,,sizeof(b));
  16. scanf("%d%d%d",&n,&x,&y);
  17. for(int i=;i<=n;++i)
  18. {
  19. scanf("%d%d",&a[i],&b[i]);
  20. r=max(r,max(a[i],b[i]));
  21. }
  22. }
  23. bool check(int tim)
  24. {
  25. int f[]={};
  26. memset(f,-,sizeof(f));
  27. f[]=;
  28. for(int i=;i<=x;++i)
  29. if(tim>=a[]*i)
  30. f[i]=(tim-a[]*i)/b[];
  31. if(f[x]>=y) return true;
  32. for(int i=;i<=n;++i)
  33. {
  34. for(int k=x;k>=;--k)
  35. for(int j=k;j>=;--j)/*for(int j=0;j<=k;--j),结果更新f[i][k]的时候用的是他本身,如果改为for(int j=0;j<k;--j),又不能用f[i-1][k]来更新f[i][k],所以就改为了倒序*/
  36. if(tim>=(k-j)*a[i]&&f[j]!=-)
  37. f[k]=max(f[k],f[j]+(tim-a[i]*(k-j))/b[i]);
  38. if(f[x]>=y) return true;
  39. }
  40. return false;
  41. }
  42. int find_ans(int l,int r)
  43. {
  44. int mid;
  45. while(l<=r)
  46. {
  47. mid=(l+r)>>;
  48. if(check(mid))
  49. {
  50. r=mid-;
  51. }
  52. else l=mid+;
  53. }
  54. return l;
  55. }
  56. int main()
  57. {
  58. scanf("%d",&T);
  59. int topt=;
  60. while(T--)
  61. {
  62. ++topt;
  63. int l=,r=;
  64. input(r);
  65. r=r**max(x,y);
  66. printf("Case %d: %d\n",topt,find_ans(l,r));
  67. }
  68. return ;
  69. }
 

二分+DP HDU 3433 A Task Process的更多相关文章

  1. hdu 3433 A Task Process 二分+dp

    A Task Process Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  2. hdu 3433 A Task Process(dp+二分)

    题目链接 题意:n个人, 要完成a个x任务, b个y任务. 求,最短的时间 思路:由于时间较大,用 二分来找时间. dp[i][j]表示 i个人完成j个x任务, 最多能完成的y任务个数 这个题 不是很 ...

  3. Hadoop:Task process exit with nonzero status of 1 异常

    在运行hadoop程序时经常遇到异常 java.io.IOException: Task process exit with nonzero status of 1.网上很多博文都说是磁盘不够的问题. ...

  4. Linux中的task,process, thread 简介

    本文的主要目的是介绍在Linux内核中,task,process, thread这3个名字之间的区别和联系.并且和WINDOWS中的相应观念进行比较.如果你已经很清楚了,那么就不用往下看了. LINU ...

  5. Activity, Service,Task, Process and Thread之间的关系

    Activity, Service,Task, Process and Thread之间到底是什么关系呢? 首先我们来看下Task的定义,Google是这样定义Task的:a task is what ...

  6. hadoop系列 第三坑: Task process exit with nonzero status of 137

    跑MR的时候抛出异常: java.lang.Throwable: Child Error at org.apache.hadoop.mapred.TaskRunner.run(TaskRunner.j ...

  7. 2018.10.24 NOIP模拟 小 C 的数组(二分+dp)

    传送门 考试自己yyyyyy的乱搞的没过大样例二分+dp二分+dp二分+dp过了606060把我自己都吓到了! 这么说来乱搞跟被卡常的正解比只少101010分? 那我考场不打其他暴力想正解血亏啊. 正 ...

  8. 「学习笔记」wqs二分/dp凸优化

    [学习笔记]wqs二分/DP凸优化 从一个经典问题谈起: 有一个长度为 \(n\) 的序列 \(a\),要求找出恰好 \(k\) 个不相交的连续子序列,使得这 \(k\) 个序列的和最大 \(1 \l ...

  9. 【bzoj1044】[HAOI2008]木棍分割 二分+dp

    题目描述 有n根木棍, 第i根木棍的长度为Li,n根木棍依次连结了一起, 总共有n-1个连接处. 现在允许你最多砍断m个连接处, 砍完后n根木棍被分成了很多段,要求满足总长度最大的一段长度最小, 并且 ...

随机推荐

  1. 泛函编程(11)-延后计算-lazy evaluation

    延后计算(lazy evaluation)是指将一个表达式的值计算向后拖延直到这个表达式真正被使用的时候.在讨论lazy-evaluation之前,先对泛函编程中比较特别的一个语言属性”计算时机“(s ...

  2. 自定义XML动态配置程序

    概述 1 在做程序开发时,我们往往要用到如下两个基本模块 1> 设置程序的基础参数,如分页的参数.邮件参数等: 2> 在基于表驱动开发时,即把一些判断的逻辑放在表数据中: 2 在这两个基本 ...

  3. [js开源组件开发]js手机联动选择日期 开源git

    js手机联动选择日期 这里在前面的<js手机联动选择地区>的基础上,改造数据源之后形成的一个日期的选择器,当然你可以使用之前的PC上模式的<日期控件>,它同时也支持手机端,ht ...

  4. jquery实现轮播

    HTML代码: <div class="ad"> <ul class="slider"> <li><img src=& ...

  5. ALV常用参数详细描述

    调用功能模块: CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_interface_check        = ''               ...

  6. miniSipServer简单而不简单,轻松落地,实现电脑对固话、手机通讯

    最近沉迷于SIP通讯,网内通讯全免费,落地也就几分钱,而且无漫游全国拨打,想想真是心动呢,只要有网落就ok!. 对于sipserver,现在的市场上软件很多,免费的.收费的应有尽有,这里不一一例举.综 ...

  7. OC--第一个程序

    #import <Foundation/Foundation.h> //导入foundation.h文件 // C语言函数声明 void MyFun(BOOL bol); int main ...

  8. Git学习 --> 个人常用命令add,commit以及push

    Git命令行配置1 安装Github2 安装msysgit3 要配置用户名和油箱  git config --global user.name <用户名> 我的命令就是:git confi ...

  9. UVa 100 - The 3n + 1 problem(函数循环长度)

    题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&pa ...

  10. 谈谈JavaScript的2种主要继承方式

    今天给自己巩固一下js的继承知识,基础不好,有不对的地方,请尽量拍砖,越重越好. js继承方法最主要的是2种,一种是通过原型的方式,一种是通过借用call&apply的构造函数方式. 1.原型 ...