#include <iostream> using namespace std; int main() { int g1, s1, b1; int g2, s2, b2; cin >> g1; cin >> s1; cin >> b1; cin >> g2; cin >> s2; cin >> b2; int count = 0; int b3 = 0; int s3 = 0; if (b1 < b2) { while (b1<b2) { if (s1 > 0) { s1--; b1 += 9; count++; } else { if (g1 >0) { g1--; s1 += 9; count++; } else { cout << -1; return 0; } } } } else { b3 = b2 - b1; } if (s1 < s2) { while (s1<s2) { if (b3 >= 11) { b3 -= 11; count++; s1++; } if (g1 > 0) { g1--; s1 += 9; count++; } else { cout << -1; return 0; } } } else { s3 = s2 - s1; } if (g1 < g2) { if (s3 >= 11) { g1++; s3 -= 11; count++; } else if (b3 >= 121) { b3 -= 121; count += 12; g1++; } else { cout << -1; return 0; } } cout << count; return 0; }
点赞 评论

相关推荐

脾气小祖宗:这简历摸到都得狠狠地消毒液洗手😂
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务