注释掉的代码 WA。
ins 函数中注释部分和正常部分是不是只有精度的差别,如果是,为什么差这么多啊
#include <bits/stdc++.h>
using namespace std;
using ubt = long long;
using dub = long double;
#define IL inline
#define vec vector
#define bg begin
#define eb emplace_back
#define emp emplace
#define fi first
#define se second
using pii = pair<int, int>;
IL int _R() { int x; cin >> x; return x; }
const dub eps = 1e-6;
const int N = 500;
const int maxN = N + 3;
int n, m;
struct node {
array<dub, maxN> A;
auto &operator [] (int i) { return A.at(i); }
int c;
} a[maxN];
node d[maxN];
bool ins(auto A) {
for (int i = 1; i <= m; i++)
if (fabs(A[i]) >= eps) {
if (fabs(d[i][i]) < eps)
return d[i] = A, true;
dub T = A[i] / d[i][i];
A[i] = 0;
for (int j = i + 1; j <= m; j++)
A[j] -= d[i][j] * T;
// dub T = d[i][i] / A[i];
// A[i] = 0;
// for (int j = i + 1; j <= m; j++)
// A[j] = A[j] * T - d[i][j];
}
return false;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
n = _R(), m = _R();
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
a[i][j] = _R();
for (int i = 1; i <= n; i++)
a[i].c = _R();
sort(a + 1, a + n + 1, [](const auto &A, const auto &B) {
return A.c < B.c;
});
int cnt = 0, ans = 0;
for (int i = 1; i <= n; i++)
if (ins(a[i]))
cnt++, ans += a[i].c;
cout << cnt << ' ' << ans << '\n';
}