mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 17:48:48 +00:00
parent
8033906aa2
commit
94feba5a44
76
LibreOJ/2108/2108.cpp
Normal file
76
LibreOJ/2108/2108.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 505;
|
||||
const double eps = 1e-4;
|
||||
|
||||
int n, m, ans, sum;
|
||||
double p[N][N];
|
||||
|
||||
struct node {
|
||||
int w;
|
||||
double v[N];
|
||||
|
||||
double& operator[](const int& _i) {
|
||||
return v[_i];
|
||||
}
|
||||
|
||||
bool operator<(const node& _y) const {
|
||||
return w < _y.w;
|
||||
}
|
||||
} q[N];
|
||||
|
||||
inline bool insert(double* a) {
|
||||
for (int i = 1; i <= m; i++) {
|
||||
if (std::abs(a[i]) > eps) {
|
||||
if (std::abs(p[i][i]) > eps) { // > 0
|
||||
double k = a[i] / p[i][i];
|
||||
for (int j = i; j <= m; j++) {
|
||||
a[j] -= k * p[i][j];
|
||||
}
|
||||
} else {
|
||||
for (int j = i; j <= m; j++) {
|
||||
p[i][j] = a[j];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> m;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= m; j++) {
|
||||
cin >> q[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> q[i].w;
|
||||
}
|
||||
|
||||
std::sort(q + 1, q + 1 + n);
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
if (insert(q[i].v)) {
|
||||
ans++;
|
||||
sum += q[i].w;
|
||||
}
|
||||
}
|
||||
|
||||
cout << ans << ' ' << sum << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
LibreOJ/2108/data/purchase1.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase1.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase10.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase10.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase2.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase2.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase3.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase3.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase4.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase4.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase5.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase5.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase6.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase6.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase7.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase7.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase8.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase8.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase9.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2108/data/purchase9.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2108/data/purchase9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user