답안 #4448

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
4448 2013-10-06T19:45:06 Z model_code 택배 (KOI13_delivery) C++
100 / 100
16 ms 1224 KB
#include <stdio.h>
#include <algorithm>
using namespace std;

const int N=2222,M=11111; //
int n,c,m;
struct Box{int a,b,t;};
Box a[M];
int truck[N],x,v;
int ans;

int cmp(const Box &p,const Box &q){return p.b<q.b||(p.b==q.b&&p.a>q.a);}
int min(int p,int q){return p<q?p:q;}

int main()
{
	int i,j;
	scanf("%d%d%d",&n,&c,&m);
	for(i=0;i<m;++i)
		scanf("%d%d%d",&a[i].a,&a[i].b,&a[i].t);
	sort(a,a+m,cmp);
	
	ans=0;
	for(i=0;i<m;++i)
	{
		x=0;
		for(j=a[i].a;j<a[i].b;++j)
			if(truck[j]>x) x=truck[j];
		v=min(a[i].t,c-x);
		for(j=a[i].a;j<a[i].b;++j)
			truck[j]+=v;
		ans+=v;
	}
	printf("%d\n",ans);
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1224 KB Output is correct
2 Correct 0 ms 1224 KB Output is correct
3 Correct 0 ms 1224 KB Output is correct
4 Correct 0 ms 1224 KB Output is correct
5 Correct 0 ms 1224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1224 KB Output is correct
2 Correct 0 ms 1224 KB Output is correct
3 Correct 0 ms 1224 KB Output is correct
4 Correct 0 ms 1224 KB Output is correct
5 Correct 0 ms 1224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1224 KB Output is correct
2 Correct 0 ms 1224 KB Output is correct
3 Correct 0 ms 1224 KB Output is correct
4 Correct 0 ms 1224 KB Output is correct
5 Correct 0 ms 1224 KB Output is correct
6 Correct 0 ms 1224 KB Output is correct
7 Correct 0 ms 1224 KB Output is correct
8 Correct 0 ms 1224 KB Output is correct
9 Correct 0 ms 1224 KB Output is correct
10 Correct 0 ms 1224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1224 KB Output is correct
2 Correct 0 ms 1224 KB Output is correct
3 Correct 0 ms 1224 KB Output is correct
4 Correct 0 ms 1224 KB Output is correct
5 Correct 0 ms 1224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1224 KB Output is correct
2 Correct 0 ms 1224 KB Output is correct
3 Correct 16 ms 1224 KB Output is correct
4 Correct 16 ms 1224 KB Output is correct
5 Correct 16 ms 1224 KB Output is correct