Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int a, b, c, k;
- int count = 0;
- cin >> a >> b >> c >> k;
- while (a > 0 || b > 0 || c > 0) {
- int buf = k;
- while (buf - 3 >= 0 && c > 0) {
- c--;
- buf -= 3;
- }
- while (buf - 2 >= 0 && b > 0) {
- b--;
- buf -= 2;
- }
- while (buf - 1 >= 0 && a > 0) {
- a--;
- buf -= 1;
- }
- if (buf == 0) {
- count++;
- } else {
- while (b > 0 && buf > 0) {
- b--;
- buf -= 2;
- }
- if (buf <= 0) {
- count++;
- } else {
- while (c > 0 && buf > 0) {
- c--;
- buf -= 3;
- }
- if (buf <= 0) {
- count++;
- }
- }
- }
- }
- cout << count;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement