QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#79424 | #2457. Cheese, If You Please | kexun | WA | 0ms | 3824kb | C++14 | 1.5kb | 2023-02-20 08:18:13 | 2023-02-20 08:18:15 |
Judging History
answer
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
const int N = 105, M = 105;
const long double eps=1e-10;
int n, m, id[105];
long double a[55][55], ans[55];
void Pivot(int l, int e) {
swap(id[l + n], id[e]);
long double t = a[l][e];
a[l][e]=1;
for (int i = 0; i <= n; ++i) a[l][i] /= t;
for (int i = 0; i <= m; ++i)
if (i != l && fabs(a[i][e]) > eps) {
t = a[i][e];
a[i][e] = 0;
for (int j = 0; j <= n; ++j)
a[i][j] -= t * a[l][j];
}
}
bool Simplex() {
while (1) {
int l = 0, e = 0;
long double mn = 1e+50;
for (int i = 1; i <= n; ++i)
if (a[0][i] > eps) {
e = i;
break;
}
if (!e) break;
for (int i = 1; i <= m; ++i)
if (a[i][e] > eps && a[i][0] / a[i][e] < mn)
mn = a[i][0] / a[i][e], l = i;
if (!l) return false;
Pivot(l, e);
}
return true;
}
int main() {
cin >> m >> n;
for (int i = 1; i <= m; ++i) cin >> a[i][0];
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
cin >> a[j][i];
a[j][i] /= 100;
}
cin >> a[0][i];
}
for (int i = 1; i <= n; ++i) id[i] = i;
if (Simplex()) {
double ans = -a[0][0];
printf("%.2lf\n", ans + eps);
}
else while(1);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3824kb
input:
4 4 100 0 123 456 10.0 20.0 30.0 40.0 2.56 40.0 0.0 25.0 35.0 3.84 40.0 30.0 20.0 10.0 1.23 33.0 0.0 34.0 33.0 4.23
output:
0.00
result:
wrong answer 1st lines differ - expected: '1281.82', found: '0.00'