This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<cstdio>
#include<algorithm>
struct delivery
{
int start;
int end;
int howmany;
} d[10000];
inline bool operator <(const delivery &a,const delivery &b)
{
if(a.end!=b.end)return a.end<b.end;
if(a.start!=b.start)return a.start>b.start;
return a.howmany>b.howmany;
}
int a[2001];
int main()
{
int i,j,n,m,c,res=0,min;
scanf("%d%d%d",&n,&c,&m);
for(i=0;i<m;i++)scanf("%d%d%d",&d[i].start,&d[i].end,&d[i].howmany);
std::sort(d,d+m);
for(i=0;i<m;i++)
{
min=d[i].howmany;
for(j=d[i].start;j<d[i].end;j++)if(c-a[j]<min)min=c-a[j];
res+=min;
for(j=d[i].start;j<d[i].end;j++)a[j]+=min;
}
printf("%d",res);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |