QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#79426 | #2457. Cheese, If You Please | kexun | AC ✓ | 3ms | 3844kb | C++14 | 1.5kb | 2023-02-20 08:19:11 | 2023-02-20 08:19:12 |
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 + 1e-8);
}
else while(1);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3632kb
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:
1281.82
result:
ok single line: '1281.82'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3636kb
input:
4 4 0 0 0 0 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:
ok single line: '0.00'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3672kb
input:
2 3 100 100 99.9 0.1 2.00 0.1 99.9 2.00 50.0 50.0 0.75
output:
400.00
result:
ok single line: '400.00'
Test #4:
score: 0
Accepted
time: 2ms
memory: 3820kb
input:
5 5 451 82 17 6 372 20.0 20.0 15.5 22.3 22.2 1.88 9.5 47.8 0.0 14.2 28.5 6.13 0.0 45.7 18.1 9.0 27.2 0.75 31.5 37.1 5.2 5.2 21.0 3.01 29.3 25.0 4.1 20.8 20.8 8.42
output:
347.31
result:
ok single line: '347.31'
Test #5:
score: 0
Accepted
time: 2ms
memory: 3704kb
input:
5 5 226 180 167 396 242 10.5 21.0 26.3 0.0 42.2 8.25 6.8 31.0 20.6 6.8 34.8 9.11 16.6 12.5 29.1 33.5 8.3 8.27 20.0 0.0 10.0 45.0 25.0 2.31 41.1 9.0 4.5 4.5 40.9 4.52
output:
6721.33
result:
ok single line: '6721.33'
Test #6:
score: 0
Accepted
time: 2ms
memory: 3784kb
input:
5 5 126 30 246 186 389 26.6 10.0 6.6 33.5 23.3 3.63 34.7 39.3 4.3 21.7 0.0 3.21 13.6 22.7 36.5 4.5 22.7 2.57 17.6 0.0 29.4 11.7 41.3 6.45 19.2 11.5 7.6 38.7 23.0 0.10
output:
4617.61
result:
ok single line: '4617.61'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
5 5 339 260 429 445 399 3.4 24.1 31.2 10.3 31.0 5.24 32.4 7.1 28.5 3.5 28.5 0.07 28.0 12.0 16.0 4.0 40.0 3.96 13.6 45.6 13.6 22.7 4.5 2.55 0.0 50.2 5.5 27.7 16.6 4.32
output:
6008.15
result:
ok single line: '6008.15'
Test #8:
score: 0
Accepted
time: 2ms
memory: 3768kb
input:
5 5 409 245 299 471 438 5.8 17.6 23.5 26.7 26.4 1.22 41.8 4.1 33.3 12.5 8.3 6.25 20.8 8.3 20.8 16.6 33.5 4.39 0.0 30.7 23.0 7.6 38.7 6.04 25.1 20.8 12.5 25.0 16.6 6.30
output:
9305.29
result:
ok single line: '9305.29'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
10 10 427 141 263 17 49 70 217 446 469 144 7.0 14.0 10.5 5.2 12.2 0.0 10.5 16.2 8.7 15.7 5.05 18.8 10.2 8.1 14.2 6.1 4.0 6.1 16.3 8.1 8.1 8.02 14.2 0.0 4.7 7.1 4.7 9.5 9.5 21.8 11.9 16.6 5.12 14.8 14.2 4.2 0.0 12.8 1.4 14.2 10.0 14.2 14.2 6.39 13.4 3.8 3.8 15.9 9.6 3.8 15.3 15.3 15.3 3.8 7.81 3.7 1....
output:
3110.29
result:
ok single line: '3110.29'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
10 10 309 390 261 50 484 164 286 415 472 62 12.9 12.9 14.5 16.3 14.5 14.5 0.0 9.6 0.0 4.8 9.69 15.6 9.8 1.9 20.0 0.0 7.8 11.7 11.7 17.6 3.9 1.77 11.3 19.2 13.2 11.3 11.3 5.6 3.7 5.6 18.8 0.0 3.53 3.8 7.6 17.8 17.3 5.7 9.6 15.3 1.9 13.4 7.6 1.54 21.7 12.7 12.7 19.1 2.1 6.3 2.1 0.0 12.7 10.6 0.24 16.2...
output:
4858.99
result:
ok single line: '4858.99'
Test #11:
score: 0
Accepted
time: 2ms
memory: 3680kb
input:
10 10 60 478 72 235 239 95 224 173 374 301 0.0 8.8 13.3 0.0 15.5 17.7 22.6 15.5 0.0 6.6 0.59 16.9 15.0 10.0 15.0 10.0 3.3 16.6 6.6 3.3 3.3 2.85 12.0 14.0 12.0 12.0 10.0 0.0 10.0 0.0 18.0 12.0 2.12 14.7 16.9 16.3 11.4 4.9 14.7 1.6 3.2 6.5 9.8 9.07 7.4 9.2 1.8 3.7 11.1 14.8 12.9 3.7 18.8 16.6 3.93 15....
output:
5685.91
result:
ok single line: '5685.91'
Test #12:
score: 0
Accepted
time: 2ms
memory: 3612kb
input:
10 10 353 169 319 67 202 347 480 272 2 460 7.1 0.0 21.4 0.0 0.0 0.0 19.0 24.0 16.6 11.9 0.66 11.7 9.8 19.9 19.6 19.6 1.9 5.8 1.9 0.0 9.8 6.17 4.2 21.8 4.2 6.3 19.1 4.2 8.5 21.2 4.2 6.3 5.10 19.9 0.0 17.6 17.6 9.8 7.8 7.8 1.9 0.0 17.6 1.61 7.6 25.9 20.5 0.0 0.0 5.1 5.1 0.0 15.3 20.5 4.84 11.6 13.9 11...
output:
5003.95
result:
ok single line: '5003.95'
Test #13:
score: 0
Accepted
time: 2ms
memory: 3708kb
input:
10 10 154 302 174 325 307 404 196 367 383 138 10.2 17.9 2.5 0.0 17.9 0.0 10.2 7.6 10.2 23.5 2.97 12.5 3.5 0.0 18.1 10.7 7.1 10.7 10.7 16.0 10.7 7.11 5.7 19.6 1.9 11.5 15.3 3.8 9.6 13.4 1.9 17.3 5.41 4.0 0.0 18.3 20.7 18.3 6.1 10.2 6.1 6.1 10.2 7.49 14.8 12.9 3.7 5.5 5.5 18.8 12.9 11.1 7.4 7.4 1.92 1...
output:
9847.12
result:
ok single line: '9847.12'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
25 25 421 481 237 152 138 392 366 322 137 231 129 322 286 235 127 253 122 461 170 275 342 194 260 159 47 2.0 6.2 4.1 8.5 6.2 4.8 0.6 4.8 2.7 6.9 2.7 2.7 2.7 0.0 0.6 4.8 6.2 4.1 5.5 5.5 4.8 6.2 1.3 4.1 2.0 5.98 6.6 0.0 4.4 0.0 1.4 5.1 4.4 5.9 2.2 5.9 8.2 5.9 5.9 3.7 6.6 7.4 0.7 0.7 0.0 3.7 7.4 2.2 0....
output:
23509.69
result:
ok single line: '23509.69'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
25 25 483 445 478 341 288 44 453 130 129 369 390 0 161 273 182 217 31 74 235 471 34 24 448 197 129 3.4 6.2 6.2 5.5 6.2 0.6 0.0 0.6 5.5 9.2 5.5 4.8 0.6 4.1 6.9 6.2 1.3 3.4 3.4 0.6 6.9 3.4 6.2 2.7 0.6 9.39 9.1 5.0 5.8 5.8 0.0 8.3 0.0 5.0 5.0 7.5 6.6 3.3 1.6 0.8 5.8 1.6 4.1 0.0 0.0 6.6 6.6 1.6 8.3 1.6 ...
output:
1368.67
result:
ok single line: '1368.67'
Test #16:
score: 0
Accepted
time: 2ms
memory: 3652kb
input:
25 25 45 439 216 498 348 303 264 228 195 235 478 117 122 212 269 117 380 455 43 113 120 227 20 64 24 2.4 0.0 5.6 2.4 4.0 6.5 7.3 2.4 0.0 4.8 7.3 6.5 2.4 4.0 3.2 5.6 2.4 5.6 0.0 4.0 0.8 9.1 2.4 6.5 4.8 3.05 4.0 1.0 0.0 0.0 0.0 10.9 7.1 1.0 5.1 6.1 1.0 2.0 10.2 7.1 4.0 2.0 8.1 4.0 6.1 3.0 0.0 10.2 2.0...
output:
10355.15
result:
ok single line: '10355.15'
Test #17:
score: 0
Accepted
time: 2ms
memory: 3844kb
input:
25 25 103 333 246 200 141 47 50 308 418 484 253 187 140 225 127 199 184 220 307 402 404 350 148 426 91 3.0 6.1 1.0 0.0 6.1 11.3 1.0 0.0 1.0 0.0 9.2 0.0 5.1 5.1 6.1 0.0 10.3 5.1 1.0 5.1 7.2 5.1 4.1 5.1 2.0 4.51 2.0 0.0 3.0 9.2 1.0 4.1 1.0 9.2 7.2 0.0 5.1 7.2 11.3 2.0 0.0 0.0 9.2 7.2 3.0 3.0 1.0 4.1 1...
output:
22290.50
result:
ok single line: '22290.50'
Test #18:
score: 0
Accepted
time: 2ms
memory: 3844kb
input:
25 25 412 205 39 85 213 338 399 476 83 328 474 335 206 198 239 288 355 327 485 105 226 447 392 305 384 6.6 2.2 2.2 2.9 8.5 0.0 3.7 4.4 5.1 4.4 2.2 5.1 0.0 5.9 6.6 7.4 2.9 5.1 2.9 2.9 6.6 0.0 5.1 0.7 6.6 6.10 2.0 2.7 6.2 8.3 1.3 4.8 6.2 6.2 0.0 6.2 6.2 4.1 6.9 6.9 2.7 0.0 4.1 0.0 4.8 6.9 2.7 1.3 5.5 ...
output:
29367.13
result:
ok single line: '29367.13'
Test #19:
score: 0
Accepted
time: 3ms
memory: 3816kb
input:
50 50 279 359 259 254 190 166 456 57 135 162 223 110 202 305 408 320 445 269 46 477 397 37 492 296 161 390 188 211 258 384 379 378 343 156 243 235 273 265 26 239 233 255 481 351 394 291 493 470 243 479 2.4 0.0 2.8 2.8 2.0 0.0 3.2 2.4 2.8 2.8 1.6 3.6 0.8 2.8 0.0 0.0 2.8 3.2 2.4 6.0 2.0 2.8 3.6 3.6 0....
output:
26918.50
result:
ok single line: '26918.50'
Test #20:
score: 0
Accepted
time: 1ms
memory: 3716kb
input:
50 50 266 407 294 245 194 40 126 468 226 153 20 235 423 46 46 358 323 267 165 99 441 301 456 342 103 393 302 226 27 466 388 264 253 62 340 71 490 334 33 458 10 101 484 18 495 249 64 466 485 205 3.3 2.2 1.8 0.7 1.8 2.6 1.5 2.2 3.3 1.1 3.0 0.0 0.7 0.7 1.5 1.8 1.1 3.3 0.0 3.3 1.1 2.2 3.0 1.1 1.5 3.0 1....
output:
11215.05
result:
ok single line: '11215.05'
Test #21:
score: 0
Accepted
time: 3ms
memory: 3684kb
input:
50 50 408 363 460 321 60 233 116 459 295 306 500 102 462 55 453 40 19 446 461 426 211 320 279 334 422 21 303 163 55 72 69 450 290 162 221 473 436 118 346 104 389 111 37 59 157 211 184 9 194 56 6.4 3.0 0.0 1.5 2.2 1.5 2.6 0.0 3.0 2.6 1.1 2.6 1.1 3.8 2.6 2.2 1.9 1.1 3.4 3.4 0.0 3.4 1.1 0.7 2.2 2.2 1.5...
output:
12440.48
result:
ok single line: '12440.48'
Test #22:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
50 50 317 437 460 242 61 264 462 351 376 371 455 426 58 375 190 130 167 359 378 13 103 66 277 250 460 197 267 33 192 23 368 89 219 451 25 228 175 238 285 69 366 58 427 402 482 182 190 343 277 105 2.6 3.0 1.1 3.3 0.7 3.3 2.2 1.1 2.6 0.7 2.2 0.0 2.6 3.0 2.2 2.6 1.8 5.9 3.0 1.5 0.0 3.3 2.2 0.7 2.2 1.1 ...
output:
15979.87
result:
ok single line: '15979.87'
Test #23:
score: 0
Accepted
time: 1ms
memory: 3816kb
input:
50 50 454 323 100 5 152 94 500 55 327 253 131 41 500 310 158 353 69 436 109 103 228 472 314 129 232 117 420 40 289 41 43 5 98 1 165 124 132 315 273 375 346 35 122 150 441 26 52 305 500 149 3.5 2.6 1.7 0.0 6.5 1.3 0.4 3.5 0.4 1.3 4.0 3.1 1.7 2.2 0.4 1.7 3.1 1.3 1.3 1.7 0.8 2.2 3.1 2.6 2.6 3.1 1.7 4.4...
output:
2225.61
result:
ok single line: '2225.61'
Test #24:
score: 0
Accepted
time: 2ms
memory: 3832kb
input:
10 50 195 438 303 426 18 9 322 7 99 449 2.8 26.2 14.2 5.7 5.7 2.8 8.5 14.2 17.1 2.8 7.01 15.0 1.8 16.9 16.9 11.3 9.4 1.8 19.5 1.8 5.6 8.69 19.8 9.8 13.7 0.0 17.6 0.0 0.0 7.8 17.6 13.7 1.30 12.5 18.7 22.1 0.0 0.0 6.2 12.5 18.7 6.2 3.1 8.55 13.3 8.8 15.5 20.4 0.0 6.6 0.0 15.5 13.3 6.6 4.01 20.0 18.0 2...
output:
1806.46
result:
ok single line: '1806.46'
Test #25:
score: 0
Accepted
time: 2ms
memory: 3784kb
input:
10 50 49 308 20 127 32 106 459 486 365 376 13.8 8.3 5.5 13.8 2.7 22.7 0.0 11.1 16.6 5.5 0.80 16.9 8.3 3.3 15.0 15.0 11.6 8.3 3.3 13.3 5.0 1.95 23.1 2.2 0.0 4.5 6.8 22.7 13.6 4.5 18.1 4.5 6.60 9.5 11.9 14.2 0.0 19.4 7.1 16.6 16.6 4.7 0.0 6.87 12.7 9.0 12.7 18.7 5.4 7.2 18.1 7.2 5.4 3.6 9.01 5.5 7.4 1...
output:
6733.59
result:
ok single line: '6733.59'
Test #26:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
10 50 457 116 326 79 468 226 21 197 330 341 15.6 1.9 7.8 0.0 11.7 11.7 13.7 1.9 15.6 20.1 0.86 3.5 7.0 1.7 15.7 18.0 15.7 14.0 7.0 8.7 8.7 6.99 5.8 2.9 11.7 0.0 8.8 5.8 11.7 20.5 29.9 2.9 6.63 22.5 22.2 0.0 17.7 11.1 6.6 11.1 0.0 4.4 4.4 6.46 15.1 0.0 0.0 9.0 9.0 24.7 18.1 3.0 9.0 12.1 3.56 5.2 18.4...
output:
10026.59
result:
ok single line: '10026.59'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
10 50 196 210 490 73 50 469 96 376 410 146 19.3 11.3 1.8 0.0 15.0 0.0 7.5 16.9 15.0 13.2 5.48 2.8 14.2 11.4 0.0 2.8 2.8 26.2 14.2 11.4 14.2 3.37 2.4 7.3 4.8 12.1 2.4 12.1 0.0 24.8 19.5 14.6 4.53 5.1 5.1 15.3 12.8 20.8 5.1 0.0 12.8 2.5 20.5 9.23 13.7 7.8 0.0 9.8 19.9 9.8 7.8 7.8 5.8 17.6 4.25 3.5 15....
output:
12764.31
result:
ok single line: '12764.31'
Test #28:
score: 0
Accepted
time: 2ms
memory: 3784kb
input:
10 50 366 147 246 200 271 154 477 249 448 99 12.1 2.4 7.3 14.6 17.0 4.8 0.0 19.9 2.4 19.5 7.31 16.3 12.2 4.0 0.0 10.2 10.2 20.7 20.4 2.0 4.0 9.12 16.4 1.6 16.1 1.6 3.2 16.1 1.6 16.1 11.2 16.1 2.72 1.6 4.9 13.1 8.1 9.8 13.1 16.8 8.1 11.4 13.1 2.11 10.0 11.6 0.0 5.0 10.0 15.0 8.3 16.8 10.0 13.3 6.74 6...
output:
18019.03
result:
ok single line: '18019.03'
Test #29:
score: 0
Accepted
time: 2ms
memory: 3632kb
input:
1 1 500 100.0 10.00
output:
5000.00
result:
ok single line: '5000.00'
Test #30:
score: 0
Accepted
time: 2ms
memory: 3764kb
input:
1 3 500 100.0 1.50 100.0 2.30 100.0 1.75
output:
1150.00
result:
ok single line: '1150.00'
Test #31:
score: 0
Accepted
time: 2ms
memory: 3768kb
input:
3 2 100 150 100 50.0 50.0 0.0 3.20 0.0 50.0 50.0 2.80
output:
920.00
result:
ok single line: '920.00'
Test #32:
score: 0
Accepted
time: 2ms
memory: 3632kb
input:
3 2 100 150 100 50.0 50.0 0.0 3.20 0.0 40.0 60.0 2.80
output:
1000.00
result:
ok single line: '1000.00'