Finished g of the 226th atcoder contest
This commit is contained in:
@@ -2,8 +2,62 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void test_case(int tc){
|
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';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -12,6 +66,9 @@ int main(){
|
|||||||
ios::sync_with_stdio(0);
|
ios::sync_with_stdio(0);
|
||||||
cin.tie(0);
|
cin.tie(0);
|
||||||
|
|
||||||
|
packages[0] = 0;
|
||||||
|
lifters[0] = 0;
|
||||||
|
|
||||||
int t;
|
int t;
|
||||||
cin >> t;
|
cin >> t;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user