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

模板题。。。模板又打错了。。。

#include<bits/stdc++.h>
using namespace std;
const int N = ;
const double eps = 1e-;
int n, m, l, e;
int p[N * ];
double a[N][N * ], b[N * ][N];
void pivot(int l, int e)
{
double r = a[l][e]; a[l][e] = 1.0;
for(int i = ; i <= n; ++i) a[l][i] /= r;
p[] = ;
for(int i = ; i <= n; ++i) p[++p[]] = i;
for(int i = ; i <= m; ++i) if(i != l && abs(a[i][e]) > eps)
{
double r = a[i][e]; a[i][e] = ;
for(int j = ; j <= p[]; ++j) a[i][p[j]] -= a[l][p[j]] * r;
}
}
void simplex()
{
while(true)
{
l = e = ;
for(int i = ; i <= n; ++i) if(a[][i] > eps) { e = i; break; }
if(!e) break;
double k = 1e18;
for(int i = m; i; --i) if(a[i][e] > eps && a[i][] / a[i][e] < k)
{ k = a[i][] / a[i][e]; l = i; }
if(!l) return;
pivot(l, e);
}
printf("%d", (int)(-a[][] + 0.5));
}
int main()
{
// freopen("zjoi13_defend.in", "r", stdin);
// freopen("zjoi13_defend.out", "w", stdout);
scanf("%d%d", &n, &m);
for(int i = ; i <= n; ++i) scanf("%lf", &b[][i]);
for(int i = ; i <= m; ++i)
{
int l, r; scanf("%d%d%lf", &l, &r, &b[i][]);
for(int j = l; j <= r; ++j) b[i][j] += 1.0;
}
swap(n, m);
for(int i = ; i <= m; ++i)
for(int j = ; j <= n; ++j) a[i][j] = b[j][i];
simplex();
// fclose(stdin); fclose(stdout);
return ;
}

最新文章

  1. Microsoft .NET Framework 4.0.3版下载
  2. unsigned无符号、有符号类型的符号拓展
  3. 【读书笔记】iOS网络-异步请求与运行循环
  4. 【BZOJ】2938: [Poi2000]病毒
  5. [问题2014S10] 复旦高等代数II(13级)每周一题(第十教学周)
  6. Week,Month, Year 日期区间辅助类
  7. bootstrap学习笔记&lt;一&gt;(bootstrap用法)
  8. linux rar工具
  9. 你是怎么理解“MVC”的
  10. PHP 错误处理
  11. WPF MultiBinding后台绑定动态属性 属性改变不调用Convert的问题
  12. Scrambled Polygon(斜率排序)
  13. java 正则
  14. Android中的WebView实战详解(二)
  15. JS/jQ常用宽高及应用
  16. Spring(一)--作用、IOC容器细节、搭配环境、Spring实验
  17. python中的迭代器&amp;&amp;生成器&amp;&amp;装饰器
  18. Orchard CMS -Migration文件更新后数据库不更新的问题 new properties not updating after migrationData migration is not working?
  19. 【Servlet】监听器入门
  20. 给Array添加去重原型方法

热门文章

  1. Pycharm中通过扩展工具添加QTDesigner
  2. Docker私有仓库的构建
  3. 【原】CentOS release 6.2 安装mysql
  4. 个人总结的常用java,anroid网站
  5. 【06】AngularJS&#160;控制器
  6. ZOJ 3349 Special Subsequence
  7. Why does MySQL produce so many temporary MYD files?
  8. opengl 对投影变化函数的理解
  9. PatentTips – Shader Interfaces
  10. android调试