翻译已上传,具体题意看翻译:
- 解题思路:
-假设当前时间为 要发送一条短信,有两种策略:1、关机等,到时间打开,那么消耗电量为 ,不关机,待机等待,那么消耗电量为 ,通过贪心的方式选择其中最小的成本就是当前这条短信所消耗的电量,如果在某一条短信的时候电量到 或以下了那么就失败了。(PS:记得开 long long)
#include <iostream>
#define endl '\n'
using namespace std;
void solve(){
long long n, f, a, b;
cin >> n >> f >> a >> b;
int time = 0;
while (n--){
int m; cin >> m;
f -= min(b, a * (m - time));
time = m;
}
cout << (f > 0 ? "YES" : "NO") << endl;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t; cin >> t;
while (t--) solve();
return 0;
}