diff --git a/atcoder/beginner_contests/226/g.cpp b/atcoder/beginner_contests/226/g.cpp index 0c03bec..fc10092 100644 --- a/atcoder/beginner_contests/226/g.cpp +++ b/atcoder/beginner_contests/226/g.cpp @@ -2,8 +2,62 @@ using namespace std; -void test_case(int tc){ +typedef long long ll; +vector packages(6); +vector lifters(6); + +void pack(int i, int j){ + ll dif = min(packages[i], lifters[j]); + + // Remove carried packages and used lifters from their lists + packages[i] -= dif; + lifters[j] -= dif; + + // Add lifters that have space left + // since we don't take lifters into consideration that can carry 0 we don't need a check here + lifters[j - i] += dif; + + return; +} + +void test_case(int tc){ + for(int i = 1; i <= 5; ++i){ + cin >> packages[i]; + } + + for(int i = 1; i <= 5; ++i){ + cin >> lifters[i]; + } + + pack(5, 5); + pack(4, 4); + pack(4, 5); + pack(3, 3); + pack(3, 5); + pack(3, 4); + + for(int i = 0; i < 4; ++i){ + pack(2, 5 - i); + } + for(int i = 0; i < 5; ++i){ + pack(1, 5 - i); + } + + bool result = true; + for(int i = 1; i <= 5; ++i){ + if(packages[i] > 0){ + result = false; + break; + } + } + + // cout << "Packages left: "; + // for(int i = 0; i <= 5; ++i){ + // cout << packages[i] << " "; + // } cout << '\n'; + + cout << (result ? "Yes" : "No") << '\n'; } @@ -12,6 +66,9 @@ int main(){ ios::sync_with_stdio(0); cin.tie(0); + packages[0] = 0; + lifters[0] = 0; + int t; cin >> t;