题目:https://www.acwing.com/problem/content/description/4171/
通过率:11/13
代码:
#include<iostream>
#include<string>
#include<cmath>
#include<stdio.h>
using namespace std;
int main(){
int a,b;
int n=0,d=0,dd=0;
cin>>a>>b;
int p[30001],q[30001],x[30001],y[30001]={0};
for(int i=1;i<=b;i++){
cin>>p[i]>>q[i]>>x[i];
}
int zuixiao = 30000,i;
for(int bbb = 1;bbb<=b;bbb++){
zuixiao = 30000;
for(int dp = 1;dp<=b;dp++){
if(q[dp] < zuixiao){
i = dp;
zuixiao = q[dp];
}
}
//cout<<i<<endl;
for(int j=p[i];j<=q[i];j++){
if(y[j] == 1){
x[i]-=1;
}
}
if(x[i] > 0){
d = 0,dd = 0;
while(x[i]>0){
if(y[q[i]-d] == 0){
y[q[i]-d] +=1;
n+=1;
x[i] -= 1;
dd+=1;
//cout<<q[i]-d<<endl;
}
d+=1;
}
}
q[i] = 30001;
}
cout<<n;
}