Submission #4832

# Submission time Handle Problem Language Result Execution time Memory
4832 2014-01-04T15:31:41 Z gs13068 택배 (KOI13_delivery) C++
100 / 100
20 ms 1212 KB
#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
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
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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