2
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int package_requirement(vector<int> box_counts) {
|
||||
int answer = box_counts[5] + box_counts[4] + box_counts[3];
|
||||
// 5x5
|
||||
box_counts[0] -= min(box_counts[4] * 11, box_counts[0]);
|
||||
// 4x4
|
||||
box_counts[1] -= box_counts[3] * 5;
|
||||
if (box_counts[1] < 0) {
|
||||
// 放 1x1
|
||||
box_counts[0] -= min(-box_counts[1] * 4, box_counts[0]);
|
||||
box_counts[1] = 0;
|
||||
}
|
||||
// 3x3
|
||||
if (box_counts[2]) {
|
||||
answer += (box_counts[2] - 1) / 4 + 1;
|
||||
switch (4 - box_counts[2] % 4) {
|
||||
case 4: break;
|
||||
case 1:
|
||||
box_counts[1]--;
|
||||
box_counts[0] -= min(5, box_counts[0]);;
|
||||
// if (box_counts[1]) {
|
||||
// box_counts[1]--;
|
||||
// box_counts[0] -= min(5, box_counts[0]);;
|
||||
// } else {
|
||||
// box_counts[0] -= min(9, box_counts[0]);
|
||||
// }
|
||||
break;
|
||||
case 2:
|
||||
box_counts[1] -= 3;
|
||||
box_counts[0] -= min(6, box_counts[0]);
|
||||
break;
|
||||
case 3:
|
||||
box_counts[1] -= 5;
|
||||
box_counts[0] -= min(7, box_counts[0]);
|
||||
break;
|
||||
default:
|
||||
throw logic_error("remaining_3x3_areas must be 4(0), 1, 2, or 3");
|
||||
}
|
||||
if (box_counts[1] < 0) {
|
||||
// 放 1x1
|
||||
box_counts[0] -= min(-box_counts[1] * 4, box_counts[0]);
|
||||
box_counts[1] = 0;
|
||||
}
|
||||
}
|
||||
// 2x2
|
||||
if (box_counts[1]) {
|
||||
answer += (box_counts[1] - 1) / 9 + 1;
|
||||
int remaining_2x2_areas = 9 - box_counts[1] % 9;
|
||||
if (remaining_2x2_areas == 9) { remaining_2x2_areas = 0; }
|
||||
box_counts[0] -= min(remaining_2x2_areas * 4, box_counts[0]);
|
||||
}
|
||||
// 1x1
|
||||
if (box_counts[0]) {
|
||||
answer += (box_counts[0] - 1) / 36 + 1;
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
vector<int> box_counts(6);
|
||||
|
||||
for (;;) {
|
||||
cin >> box_counts[0] >> box_counts[1] >> box_counts[2] >> box_counts[3] >> box_counts[4] >> box_counts[5];
|
||||
if (box_counts[0] == 0 && box_counts[1] == 0 && box_counts[2] == 0 && box_counts[3] == 0 && box_counts[4] == 0
|
||||
&& box_counts[5] == 0) {
|
||||
break;
|
||||
}
|
||||
cout << package_requirement(box_counts) << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user