当前位置:网站首页>P3265 [jloi2015] equipment purchase
P3265 [jloi2015] equipment purchase
2022-07-05 06:19:00 【Strezia】
Link
Real linear basis
#define double long double
double a[N][N];
struct node {
double a[550];
int w;
bool operator < (const node &x) const {
return w < x.w;
}
}p[550];
int n, m;
double b[N][N];
bool insert(int m, double c[]) {
for(int i = m-1; i >= 0; i--) {
if(fabs(c[i]) < EPS) continue;
if(fabs(b[i][i]) < EPS) {
for(int j = 0; j < m; j++)
b[i][j] = c[j];
return true;
}
double t = c[i]/b[i][i];
for(int j = 0; j < m; j++)
if(fabs(c[i]) > EPS)
c[j] -= b[i][j] * t;
}
return false;
}
void solve() {
cin >> n >> m;
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
cin >> p[i].a[j];
for(int i = 0; i < n; i++)
{
cin >> p[i].w;
p[i].a[m] = p[i].w;
}
sort(p, p + n);
int cnt = 0, res = 0;
for(int i = 0; i < n; i++) {
if(insert(m, p[i].a)) {
cnt++;
res += p[i].w;
}
}
cout << cnt << ' ' << res << endl;
}
边栏推荐
- 对for(var i = 0;i < 5;i++) {setTimeout(() => console.log(i),1000)}的深入分析
- [rust notes] 14 set (Part 2)
- LeetCode-54
- 【LeetCode】Day94-重塑矩阵
- MySQL advanced part 1: stored procedures and functions
- Leetcode-22: bracket generation
- liunx启动redis
- Leetcode divide and conquer / dichotomy
- [rust notes] 17 concurrent (Part 1)
- 【Rust 笔记】14-集合(下)
猜你喜欢
中国剩余定理 AcWing 204. 表达整数的奇怪方式
4. Object mapping Mapster
Data visualization chart summary (II)
Navicat連接Oracle數據庫報錯ORA-28547或ORA-03135
Overview of variable resistors - structure, operation and different applications
快速使用Amazon MemoryDB并构建你专属的Redis内存数据库
【LeetCode】Easy | 20. Valid parentheses
MySQL怎么运行的系列(八)14张图说明白MySQL事务原子性和undo日志原理
QQ电脑版取消转义符输入表情
MySQL advanced part 2: storage engine
随机推荐
927. Trisection simulation
leetcode-31:下一个排列
2021apmcm post game Summary - edge detection
Is it impossible for lamda to wake up?
1041 Be Unique
Leetcode dynamic programming
__ builtin_ Popcount() counts the number of 1s, which are commonly used in bit operations
Arduino 控制的 RGB LED 无限镜
How to generate an image from text on fly at runtime
[rust notes] 13 iterator (Part 2)
LeetCode-54
Leetcode-6110: number of incremental paths in the grid graph
[rust notes] 15 string and text (Part 1)
Data visualization chart summary (I)
Matrixdb V4.5.0 was launched with a new mars2 storage engine!
数据可视化图表总结(一)
Chart. JS - Format Y axis - chart js - Formatting Y axis
MySQL advanced part 2: optimizing SQL steps
【LeetCode】Day94-重塑矩阵
LeetCode 0107. Sequence traversal of binary tree II - another method