跳到正文

题解

题解

_Separation约 1 分钟
原文
文章信息与版本

文章信息

收录
2026年6月20日
更新
2026年7月24日
篇幅
约 1 分钟
题目
CF1921C

版本

  1. v1当前

翻译已上传,具体题意看翻译:

  • 解题思路:

-假设当前时间为 time{time} 要发送一条短信,有两种策略:1、关机等,到时间打开,那么消耗电量为 b{b} ,不关机,待机等待,那么消耗电量为 mi−time∗a{m_i - time * a} ,通过贪心的方式选择其中最小的成本就是当前这条短信所消耗的电量,如果在某一条短信的时候电量到 0{0} 或以下了那么就失败了。(PS:记得开 long long)

C++
#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;
}
原文