QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#798846 | #9653. Bin Packing | jiangly (Lingyu Jiang) | AC ✓ | 0ms | 3864kb | C++23 | 930b | 2024-12-04 17:42:55 | 2024-12-04 17:42:59 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;
using F = double;
void solve() {
int h1, w1, h2, w2;
std::cin >> h1 >> w1 >> h2 >> w2;
F ans = INFINITY;
auto check = [&](int a, int b, int c, int d) {
ans = std::min(ans, 1.0 * (b + d) * std::min(a, c) + 1.0 * (b + d + (a > c ? b : d)) * std::abs(a - c) / 2);
};
check(h1, w1, h2, w2);
check(h1, w1, w2, h2);
check(w1, h1, h2, w2);
check(w1, h1, w2, h2);
std::cout << ans << "\n";
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout << std::fixed << std::setprecision(10);
int t;
std::cin >> t;
for (int i = 1; i <= t; i++) {
std::cout << "Case " << i << ": ";
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3864kb
input:
100 9 6 8 7 8 10 7 5 8 10 5 8 10 6 8 10 5 5 10 10 6 9 7 5 5 6 10 9 9 10 5 5 6 7 9 5 9 6 10 10 8 8 10 5 9 8 10 5 5 7 9 6 9 8 8 8 7 8 10 9 8 9 9 9 7 7 6 5 8 10 7 9 8 6 5 8 10 5 9 10 6 10 7 10 6 6 8 10 8 9 7 8 6 10 10 5 6 8 10 5 5 9 9 10 6 10 10 8 8 6 6 6 6 6 9 6 5 8 8 7 6 5 9 7 8 10 6 7 8 7 7 5 79 99 ...
output:
Case 1: 113.5000000000 Case 2: 117.5000000000 Case 3: 120.0000000000 Case 4: 140.0000000000 Case 5: 137.5000000000 Case 6: 92.5000000000 Case 7: 127.5000000000 Case 8: 125.0000000000 Case 9: 91.5000000000 Case 10: 157.0000000000 Case 11: 122.0000000000 Case 12: 126.0000000000 Case 13: 92.5000000000 ...
result:
ok 100 lines
Extra Test:
score: 0
Extra Test Passed