forked from abheekd/usaco-practice
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.4 KiB
68 lines
1.4 KiB
#include <iostream>
|
|
using namespace std;
|
|
|
|
int main() {
|
|
freopen("mixmilk.in", "r", stdin);
|
|
freopen("mixmilk.out", "w", stdout);
|
|
|
|
int a_cap, a_val;
|
|
cin >> a_cap >> a_val;
|
|
int b_cap, b_val;
|
|
cin >> b_cap >> b_val;
|
|
int c_cap, c_val;
|
|
cin >> c_cap >> c_val;
|
|
|
|
for (int i = 0; i < 33; i++) {
|
|
int a_diff, b_diff, c_diff;
|
|
a_diff = abs(a_cap - a_val);
|
|
b_diff = abs(b_cap - b_val);
|
|
c_diff = abs(c_cap - c_val);
|
|
|
|
if (b_diff >= a_val) {
|
|
b_val += a_val;
|
|
a_val = 0;
|
|
} else {
|
|
b_val = b_cap;
|
|
a_val -= b_diff;
|
|
}
|
|
a_diff = abs(a_cap - a_val);
|
|
b_diff = abs(b_cap - b_val);
|
|
c_diff = abs(c_cap - c_val);
|
|
|
|
if (c_diff >= b_val) {
|
|
c_val += b_val;
|
|
b_val = 0;
|
|
} else {
|
|
c_val = c_cap;
|
|
b_val -= c_diff;
|
|
}
|
|
a_diff = abs(a_cap - a_val);
|
|
b_diff = abs(b_cap - b_val);
|
|
c_diff = abs(c_cap - c_val);
|
|
|
|
if (a_diff >= c_val) {
|
|
a_val += c_val;
|
|
c_val = 0;
|
|
} else {
|
|
a_val = a_cap;
|
|
c_val -= a_diff;
|
|
}
|
|
a_diff = abs(a_cap - a_val);
|
|
b_diff = abs(b_cap - b_val);
|
|
c_diff = abs(c_cap - c_val);
|
|
}
|
|
int a_diff, b_diff, c_diff;
|
|
a_diff = abs(a_cap - a_val);
|
|
b_diff = abs(b_cap - b_val);
|
|
c_diff = abs(c_cap - c_val);
|
|
|
|
if (b_diff >= a_val) {
|
|
b_val += a_val;
|
|
a_val = 0;
|
|
} else {
|
|
b_val = b_cap;
|
|
a_val -= b_diff;
|
|
}
|
|
|
|
cout << a_val << endl << b_val << endl << c_val << endl;
|
|
}
|
|
|