82 lines
1.4 KiB
C++
82 lines
1.4 KiB
C++
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
typedef long long ll;
|
|
|
|
vector<ll> packages(6);
|
|
vector<ll> 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';
|
|
}
|
|
|
|
|
|
|
|
int main(){
|
|
ios::sync_with_stdio(0);
|
|
cin.tie(0);
|
|
|
|
packages[0] = 0;
|
|
lifters[0] = 0;
|
|
|
|
int t;
|
|
cin >> t;
|
|
|
|
for(int tc = 1; tc <= t; ++tc){
|
|
test_case(tc);
|
|
}
|
|
|
|
cout << flush;
|
|
|
|
return 0;
|
|
} |