#include #include #include #include using namespace std; int main() { vector v(4); for (size_t i = 0; i < v.size(); ++i) { cin >> v[i]; } vector count(30 + 30 + 1); int minCount = numeric_limits::max(); for (int a = 1; a <= 30; ++a) { for (int b = a + 1; b <= 30; ++b) { for (int c = b + 1; c <= 30; ++c) { int totalCount = 0; for (size_t i = 0; i < v.size(); ++i) { fill(count.begin(), count.end(), numeric_limits::max()); count[0] = 0; for (int k = 0; k < v[i]; ++k) { if (count[k] != numeric_limits::max()) { count[k + a] = min(count[k + a], count[k] + 1); count[k + b] = min(count[k + b], count[k] + 1); count[k + c] = min(count[k + c], count[k] + 1); } } if (count[v[i]] == numeric_limits::max()) { totalCount = numeric_limits::max(); break; } totalCount += count[v[i]]; } minCount = min(minCount, totalCount); } } } cout << minCount << endl; return 0; }