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