AC on #1 #3 #10
贪心思路大致和题解1一样
//2023/4/1
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e6+10;
int num,ans;
struct house{
int b;
int e;
int t;
}a[50001];
bool vis[300001];
bool cmp(house x,house y)
{
if(x.e==y.e)
{
return x.b>y.b;
}
return x.e<y.e;
}
int main()
{
int n,m;
cin>>n>>m;
for (int i=1;i<=m;i++)
{
cin>>a[i].b>>a[i].e>>a[i].t;
}
sort(a+1,a+1+m,cmp);
for (int i=1;i<=n;i++)
{
int k=0;
for (int j=a[i].b;j<=a[i].e;j++)
{
if(vis[j]==1)
{
a[i].t--;
}
}
for (int j=a[i].t-1;j>=0;j--)
{
int h=a[i].e-j;
vis[h]=1;
ans++;
}
}
cout<<ans<<endl;
return 0;
}