A. Food for Animals:
题目链接:
题面:
题意:
有a包狗粮,b包猫粮,c包猫狗都吃粮,有x只狗,y只猫,问能否给每只动物都分配一包粮
思路:
如果x-a + y-b <= c就输出YES,否则NO
代码:
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
int main(){
int t;
cin >> t;
while(t--){
int a, b, c, x, y;
cin >> a >> b >> c >>x >> y;
int ans = x - a;
int cnt = y - b;
ans = max(0, ans);
cnt = max(0, cnt);
if(ans + cnt <= c){
cout << "YES" << endl;
}else{
cout << "NO" << endl;
}
}
return 0;
}
B. Make It Increasing
题目链接:
题面:
题意:
有n个数,可以任选一个数x变成x/2,问能否变成一个递增序列,如果可以输出操作次数,不可以输出-1
思路:
从后往