1342. Enterprise

Time limit: 5.0 second
Memory limit: 64 MB
To bind a broom it’s a hard work. As there is a very big demand for this high-tech product an brooms binding enterprise is to have a big amount of production workshops. You are to help such an enterprise to allocate the work among the workshops. Each workshop can bind from 0 to K brooms a day. Economists of the enterprise found out that each bound broom has a different prime cost: in most cases the more brooms were bound a day the less prime cost has the last broom bound that day. However, there may be more complicated situations. As a first approximation you may assume every dependence linear. So decided the economists when they determined a dependence of the next in turn broom’s prime cost on the industrial output of the workshop. You are to find out the optimal work load of the workshops.

Input

The first line contains two integers N and M (1 ≤ NM ≤ 1000) — an amount of workshops and the required industrial output of brooms, respectively.
Then workshops description follows. The (i+1)-st line describes the i-th workshops with three numbers KiPi, and Qi (1 ≤ Ki ≤ 100; 0 ≤ PiQi ≤ 1000) — they are the maximal number of brooms that can be bound at the i-th workshop a day, the prime cost of the first broom and the prime cost of Ki-th broom at the i-th workshop. As it was mentioned above the cost of j-th broom’s production is the linear with respect to j function.

Output

If the enterprise can’t produce the required number of brooms your program is to output the maximal number of brooms V that can be bound at the enterprise.
Besides, you are to output the total costs on production of M (or V if the enterprise can’t bind M) brooms with optimal allocation of industrial outputs within two digits after a decimal point.
The output format is to be as in sample outputs below.

Samples

input output
  1. 2 10
  2. 6 20 15
  3. 100 100 100
  1. Minimum possible cost: 505.00
  1. 2 10
  2. 5 30 14
  3. 1 20 20
  1. Maximum possible amount: 6
  2. Minimum possible cost: 130.00
Problem Author: Magaz Asanov and Pavel Egorov
Problem Source: USU Championship 2004
Difficulty: 861
 
题意:有n组东西 每组有若干个。价格成一个线性函数,给出上限,初始价格,终止价格。要求买够m个的最少价钱,不够m个输出买最多的最少价钱
分析:
就是比较裸的dp
  1. /**
  2. Create By yzx - stupidboy
  3. */
  4. #include <cstdio>
  5. #include <cstring>
  6. #include <cstdlib>
  7. #include <cmath>
  8. #include <deque>
  9. #include <vector>
  10. #include <queue>
  11. #include <iostream>
  12. #include <algorithm>
  13. #include <map>
  14. #include <set>
  15. #include <ctime>
  16. #include <iomanip>
  17. using namespace std;
  18. typedef long long LL;
  19. typedef double DB;
  20. #define For(i, s, t) for(int i = (s); i <= (t); i++)
  21. #define Ford(i, s, t) for(int i = (s); i >= (t); i--)
  22. #define Rep(i, t) for(int i = (0); i < (t); i++)
  23. #define Repn(i, t) for(int i = ((t)-1); i >= (0); i--)
  24. #define rep(i, x, t) for(int i = (x); i < (t); i++)
  25. #define MIT (2147483647)
  26. #define INF (1000000001)
  27. #define MLL (1000000000000000001LL)
  28. #define sz(x) ((int) (x).size())
  29. #define clr(x, y) memset(x, y, sizeof(x))
  30. #define puf push_front
  31. #define pub push_back
  32. #define pof pop_front
  33. #define pob pop_back
  34. #define ft first
  35. #define sd second
  36. #define mk make_pair
  37. inline void SetIO(string Name)
  38. {
  39. string Input = Name+".in",
  40. Output = Name+".out";
  41. freopen(Input.c_str(), "r", stdin),
  42. freopen(Output.c_str(), "w", stdout);
  43. }
  44.  
  45. inline int Getint()
  46. {
  47. int Ret = ;
  48. char Ch = ' ';
  49. bool Flag = ;
  50. while(!(Ch >= '' && Ch <= ''))
  51. {
  52. if(Ch == '-') Flag ^= ;
  53. Ch = getchar();
  54. }
  55. while(Ch >= '' && Ch <= '')
  56. {
  57. Ret = Ret * + Ch - '';
  58. Ch = getchar();
  59. }
  60. return Flag ? -Ret : Ret;
  61. }
  62.  
  63. const int N = ;
  64. int n, m;
  65. DB Arr[N][], Dp[N][N];
  66.  
  67. inline void Input()
  68. {
  69. scanf("%d%d", &n, &m);
  70. For(i, , n)
  71. Rep(j, ) scanf("%lf", &Arr[i][j]);
  72. }
  73.  
  74. inline void Solve()
  75. {
  76. Dp[][] = ;
  77. For(i, , m) Dp[][i] = 1.0 * INF;
  78. DB Delta, x, Cnt;
  79. int Len = ;
  80. For(i, , n)
  81. {
  82. For(j, , m) Dp[i][j] = Dp[i - ][j];
  83. if(Arr[i][] > ) Delta = (Arr[i][] - Arr[i][]) / (Arr[i][] - );
  84.  
  85. x = Cnt = Arr[i][];
  86. For(j, , Arr[i][])
  87. {
  88. For(k, , Len)
  89. if(Dp[i][k + j] > Dp[i - ][k] + x)
  90. Dp[i][k + j] = Dp[i - ][k] + x;
  91. Cnt += Delta;
  92. x += Cnt;
  93. }
  94.  
  95. Len += Arr[i][];
  96. if(Len > m) Len = m;
  97. }
  98.  
  99. if(Len < m)
  100. printf("Maximum possible amount: %d\n", Len);
  101. printf("Minimum possible cost: %.2f\n", Dp[n][Len]);
  102. }
  103.  
  104. int main()
  105. {
  106. #ifndef ONLINE_JUDGE
  107. SetIO("E");
  108. #endif
  109. Input();
  110. Solve();
  111. return ;
  112. }

ural 1342. Enterprise的更多相关文章

  1. Enterprise Solution 3.1 企业应用开发框架 .NET ERP/CRM/MIS 开发框架,C/S架构,SQL Server + ORM(LLBL Gen Pro) + Infragistics WinForms

    行业:基于数据库的制造行业管理软件,包含ERP.MRP.CRM.MIS.MES等企业管理软件 数据库平台:SQL Server 2005或以上 系统架构:C/S 开发技术 序号 领域 技术 1 数据库 ...

  2. 按照Enterprise Integration Pattern搭建服务系统

    在前一篇文章中,我们已经对Enterprise Integration Pattern中所包含的各个组成进行了简单地介绍.限于篇幅(20页Word以内),我并没有深入地讨论各个组成.但是如果要真正地按 ...

  3. Enterprise Integration Pattern - 组成简介

    近些年来,越来越多的Web应用正在逐渐向大型化的方向发展.它们通常都会包含一系列相互协作的子服务.在开发过程中,如何让这些子服务协同工作常常是软件开发人员所最为头疼的问题,如各个子服务之间的数据表示不 ...

  4. Enterprise Solution 开源项目资源汇总 Visual Studio Online 源代码托管 企业管理软件开发框架

    Enterprise Solution 是一套管理软件开发框架,在这个框架基础上开发出一套企业资源计划系统Enterprise Edition. 现将Enterprise Solution开发过程中遇 ...

  5. Windows 10 部署Enterprise Solution 5.5

    Windows 10正式版发布以后,新操作系统带来了许多的变化.现在新购买的电脑安装的系统应该是Windows 10.与当初用户不习惯Windows 7,购买新电脑后第一个想做的事情就是重装成XP,估 ...

  6. Enterprise Solution 企业资源计划管理软件 C/S架构,支持64位系统,企业全面应用集成,制造业信息化

    Enterprise Solution是一套完整的企业资源计划系统,功能符合众多制造业客户要求.系统以.NET Framework技术作为开发架构,完善的功能可有效地帮助企业进行运营策划,减低成本,如 ...

  7. 在数据库访问项目中使用微软企业库Enterprise Library,实现多种数据库的支持

    在我们开发很多项目中,数据访问都是必不可少的,有的需要访问Oracle.SQLServer.Mysql这些常规的数据库,也有可能访问SQLite.Access,或者一些我们可能不常用的PostgreS ...

  8. 时隔两个月再写的Echarts(Enterprise Charts,商业级数据图表)一文

    简介 ECharts,缩写来自Enterprise Charts,商业级数据图表,一个纯Javascript的图表库,可以流畅的运行在PC和移动设备上,兼容当前绝大部分浏览器(IE6/7/8/9/10 ...

  9. 数据库管理工具GUI - PremiumSoft Navicat Premium Enterprise 11.2.15 x86/x64 KEY

    转载自: 数据库管理工具GUI - PremiumSoft Navicat Premium Enterprise 11.2.15 x86/x64 KEY Navicat Premium(数据库管理工具 ...

随机推荐

  1. 手写代码自动实现自动布局,即Auto Layout的使用

    手写代码自动实现自动布局,即Auto Layout的使用,有需要的朋友可以参考下. 这里要注意几点: 对子视图的约束,若是基于父视图,要通过父视图去添加约束. 对子视图进行自动布局调整,首先对UIVi ...

  2. TCP/IP五层模型

    (2)TCP/IP五层模型的协议   应用层 传输层 网络层 数据链路层 物理层   物理层:中继器.集线器.还有我们通常说的双绞线也工作在物理层 数据链路层:网桥(现已很少使用).以太网交换机(二层 ...

  3. 51nod1057(python2计算n!)

    题目链接:www.51nod.com/onlineJudge/questionCode.html#!problemId=1057 思路:直接for循环呗- 代码: n = int( raw_input ...

  4. DB2 上copy表结构及数据

    现已有一行数据,要复制为多行,每行只有两个字段值不同,db2 没有sql server的top关键字,本只想复制几次,然后update逐条数据,发现不行. 然后想到不如临时创建一张表B,插入此行数据, ...

  5. [转] C++的STL库,vector sort排序时间复杂度 及常见容器比较

    http://www.169it.com/article/3215620760.html http://www.cnblogs.com/sharpfeng/archive/2012/09/18/269 ...

  6. 三、jQuery--Ajax基础--Ajax全接触--扩展知识(跨域)

  7. Android -- View setScale, setTranslation 对View矩阵的处理

    参考: 1.Android Matrix理论与应用详解 2.2D平面中关于矩阵(Matrix)跟图形变换的讲解 3.Android中关于矩阵(Matrix)前乘后乘的一些认识 4.Android Ma ...

  8. MyBatis魔法堂:即学即用篇

    一.前言                   本篇内容以理解MyBatis的基本用法和快速在项目中实践为目的,遵循Make it work,better and excellent原则. 技术栈为My ...

  9. 第九篇:在SOUI中使用多语言翻译

    为UI在不同地区显示不同的语言是产品国际化的一个重要要求. 在SOUI中实现了一套类似QT的多语言翻译机制:布局XML不需要调整,程序代码也不需要调整,只需要为不同地区的用户提供不同的语言翻译文件即可 ...

  10. [Unity3d插件]EasyTouch的初步使用

    对于移动平台上的RPG类的游戏,我们常用虚拟摇杆来控制人物角色的行走和一些行为,相信我们对它并不陌生,之前尝试了EasyTouch2.5,发现并没有最新版的3.1好用,2.5版本的对于自适应没有做的很 ...