纪念品商店 - 正经题解
2025-02-05 10:24:41
发布于:广东
24阅读
0回复
0点赞
如果他在商店区左边,就往右边移至商店区最左边的商店。
如果他在商店区右边,就往右边移至商店区最右边的商店。
#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int a, b, c, d;
cin >> a >> b >> c >> d;
if(c < a) d -= (a - c);
if(c > b) d -= (c - b);//移动
if(d < 0) cout << "No";//判断步数是否大于D
else cout << "Yes";
return 0;
}
时间复杂度 。
思考,如果要小码君恰好移动 步,还要特判哪种情况?
这里空空如也
有帮助,赞一个