#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1208 KB |
Output is correct |
2 |
Correct |
0 ms |
1208 KB |
Output is correct |
3 |
Correct |
0 ms |
1208 KB |
Output is correct |
4 |
Correct |
0 ms |
1208 KB |
Output is correct |
5 |
Correct |
0 ms |
1208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1208 KB |
Output is correct |
2 |
Correct |
0 ms |
1208 KB |
Output is correct |
3 |
Correct |
0 ms |
1208 KB |
Output is correct |
4 |
Correct |
0 ms |
1208 KB |
Output is correct |
5 |
Correct |
0 ms |
1208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1208 KB |
Output is correct |
2 |
Correct |
0 ms |
1208 KB |
Output is correct |
3 |
Correct |
0 ms |
1208 KB |
Output is correct |
4 |
Correct |
0 ms |
1208 KB |
Output is correct |
5 |
Correct |
0 ms |
1208 KB |
Output is correct |
6 |
Correct |
0 ms |
1208 KB |
Output is correct |
7 |
Correct |
0 ms |
1208 KB |
Output is correct |
8 |
Correct |
0 ms |
1208 KB |
Output is correct |
9 |
Correct |
0 ms |
1208 KB |
Output is correct |
10 |
Correct |
0 ms |
1208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1208 KB |
Output is correct |
2 |
Correct |
0 ms |
1208 KB |
Output is correct |
3 |
Correct |
0 ms |
1208 KB |
Output is correct |
4 |
Correct |
0 ms |
1208 KB |
Output is correct |
5 |
Correct |
0 ms |
1208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1208 KB |
Output is correct |
2 |
Correct |
0 ms |
1208 KB |
Output is correct |
3 |
Correct |
21 ms |
1208 KB |
Output is correct |
4 |
Correct |
21 ms |
1208 KB |
Output is correct |
5 |
Correct |
30 ms |
1208 KB |
Output is correct |