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 <stdio.h>
#include <algorithm>
using namespace std;
struct data{
int s,e,cnt;
bool operator<(const data&r)const{
if(e==r.e)return s>r.s;
return e<r.e;
}
}a[10010];
int s[2010],ans,mx;
int main(){
int i,j,n,c,m;
scanf("%d%d%d",&n,&c,&m);
for(i=0;i<m;++i)scanf("%d%d%d",&a[i].s,&a[i].e,&a[i].cnt);
sort(a,a+m);
for(i=0;i<m;++i){
mx=0;
for(j=a[i].s;j<a[i].e;++j)mx=max(mx,s[j]);
mx=min(a[i].cnt,c-mx);
for(j=a[i].s;j<a[i].e;++j)s[j]+=mx;
ans+=mx;
}
printf("%d",ans);
return 0;
}
# | 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... |