/* No.804 野菜が苦手 https://yukicoder.me/problems/no/804 */ #include using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int a, b, c, d; cin >> a >> b >> c >> d; int max_vege = 0; for (int vegetable = 0; vegetable <= a; vegetable++) { for (int meat = 0; meat <= b; meat++) { cerr << "vegetable, meat = " << vegetable << ", " << meat << endl; if (vegetable + meat <= d) { if (vegetable * c <= meat) { max_vege = max(max_vege, vegetable); } } } } cout << max_vege << endl; }