#include <bits/stdc++.h>
using namespace std;
#define int long long
const int NUM = 1e7;
int diff[NUM] = { 0 };
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int N, W;
cin >> N >> W;
int tmin = 0x3f3f3f3f;
int tmax = 0;
for (int i = 1; i <= N; i++) {
int s, t, p;
tmin = min(s, tmin);
tmax = max(t, tmax);
cin >> s >> t >> p;
diff[s] += p;
diff[t] -= p;
}
bool ans = true;
for (int i = tmin; i <= tmax; i++) {
diff[i] += diff[i - 1];
if (diff[i] > W)ans = false;
}
if (ans)cout << "Yes" << '\n';
else cout << "No" << '\n';
return 0;
}
lanqiao 3898
最新推荐文章于 2025-12-06 09:52:47 发布
该篇文章是关于C++编程的一个算法问题,涉及计算一个整数序列中满足特定区间更新条件(每个元素加上其前一个元素的差不超过给定值W)的解决方案。代码实现了用动态规划的方法找出答案‘Yes’或‘No’。
1573

被折叠的 条评论
为什么被折叠?



