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;
typedef pair <int,int> ppair;
pair <ppair,int> box[10001];
int n, c, m, d[2001], ans;
void input(void)
{
int i, x, y, z;
scanf("%d %d %d",&n,&c,&m);
for(i=1 ; i<=m ; i++)
{
scanf("%d %d %d",&x,&y,&z);
box[i]=make_pair(make_pair(y-1,-x),-z);
}
sort(box+1,box+m+1);
}
void process(void)
{
int i, j, mmin;
for(i=1 ; i<=m ; i++)
{
box[i].first.second*=-1;
box[i].second*=-1;
mmin=box[i].second;
for(j=box[i].first.second ; j<=box[i].first.first ; j++)
if(mmin>c-d[j])
mmin=c-d[j];
for(j=box[i].first.second ; j<=box[i].first.first ; j++)
d[j]+=mmin;
ans+=mmin;
}
}
void output(void)
{
printf("%d",ans);
}
int main(void)
{
input();
process();
output();
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... |