답안 #6082

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
6082 2014-06-19T08:23:26 Z ainta 도장 모으기 (JOI14_stamps) C++
100 / 100
112 ms 71916 KB
#include<stdio.h>
int n, T;
int w[3010][4];
long long D[3010][3010];
int main()
{
	int i, j, g, h;
	long long M;
	scanf("%d%d",&n,&T);
	for(i=1;i<=n;i++){
		scanf("%d%d%d%d",&w[i][0],&w[i][1],&w[i][2],&w[i][3]);
	}
	for(i=0;i<=n;i++){
		for(j=0;j<n;j++){
			D[i][j] = 21000000000000000LL;
		}
	}
	D[0][0] = T;
	for(i=1;i<=n;i++){
		g=w[i][2]+w[i][1];
		h=w[i][0]+w[i][1];
		for(j=0;j<n;j++){
        	if(j && D[i][j] > M + (2*j+1)*T)D[i][j] = M + (2*j+1)*T;
        	if(D[i][j] > D[i-1][j] + h + (2*j+1)*T)D[i][j] = D[i-1][j] + h + (2*j+1)*T;
        	if(j == 0 || M > D[i-1][j]) M = D[i-1][j];
        	M += g;
        }
		g=w[i][0]+w[i][3];
		h=w[i][2]+w[i][3];
        for(j=n-1;j>=0;j--){
        	if(j != n-1 && D[i][j] > M + (2*j+1)*T)D[i][j] = M + (2*j+1)*T;
        	if(j && D[i][j] > D[i-1][j] + h + (2*j+1)*T)D[i][j] = D[i-1][j] + h + (2*j+1)*T;
        	if(j == n-1 || M > D[i-1][j]) M = D[i-1][j];
        	M += g;
        }
	}
	printf("%lld\n",D[n][0]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 71916 KB Output is correct
2 Correct 0 ms 71916 KB Output is correct
3 Correct 0 ms 71916 KB Output is correct
4 Correct 0 ms 71916 KB Output is correct
5 Correct 0 ms 71916 KB Output is correct
6 Correct 0 ms 71916 KB Output is correct
7 Correct 0 ms 71916 KB Output is correct
8 Correct 0 ms 71916 KB Output is correct
9 Correct 0 ms 71916 KB Output is correct
10 Correct 0 ms 71916 KB Output is correct
11 Correct 0 ms 71916 KB Output is correct
12 Correct 0 ms 71916 KB Output is correct
13 Correct 0 ms 71916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 71916 KB Output is correct
2 Correct 0 ms 71916 KB Output is correct
3 Correct 0 ms 71916 KB Output is correct
4 Correct 0 ms 71916 KB Output is correct
5 Correct 0 ms 71916 KB Output is correct
6 Correct 0 ms 71916 KB Output is correct
7 Correct 0 ms 71916 KB Output is correct
8 Correct 0 ms 71916 KB Output is correct
9 Correct 0 ms 71916 KB Output is correct
10 Correct 0 ms 71916 KB Output is correct
11 Correct 0 ms 71916 KB Output is correct
12 Correct 0 ms 71916 KB Output is correct
13 Correct 0 ms 71916 KB Output is correct
14 Correct 0 ms 71916 KB Output is correct
15 Correct 0 ms 71916 KB Output is correct
16 Correct 0 ms 71916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 71916 KB Output is correct
2 Correct 0 ms 71916 KB Output is correct
3 Correct 100 ms 71916 KB Output is correct
4 Correct 76 ms 71916 KB Output is correct
5 Correct 64 ms 71916 KB Output is correct
6 Correct 24 ms 71916 KB Output is correct
7 Correct 20 ms 71916 KB Output is correct
8 Correct 108 ms 71916 KB Output is correct
9 Correct 108 ms 71916 KB Output is correct
10 Correct 104 ms 71916 KB Output is correct
11 Correct 104 ms 71916 KB Output is correct
12 Correct 108 ms 71916 KB Output is correct
13 Correct 96 ms 71916 KB Output is correct
14 Correct 100 ms 71916 KB Output is correct
15 Correct 112 ms 71916 KB Output is correct
16 Correct 88 ms 71916 KB Output is correct
17 Correct 104 ms 71916 KB Output is correct