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