답안 #6879

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
6879 2014-07-08T17:51:12 Z gs12117 도장 모으기 (JOI14_stamps) C++
100 / 100
84 ms 74996 KB
#include<stdio.h>
#define INF 999999999999999LL
int n;
long long int m;
long long int a[100100];
long long int b[100100];
long long int c[100100];
long long int d[100100];
long long int dp[3010][3010];
long long int stp;
int main(){
//	freopen("input.txt","r",stdin);
	int i,j;
	scanf("%d%lld",&n,&m);
	dp[0][0]=m;
	for(i=1;i<=n;i++){
		dp[0][i]=INF;
	}
	stp=INF;
	for(i=0;i<n;i++){
		scanf("%lld%lld%lld%lld",&a[i],&b[i],&c[i],&d[i]);
		if(stp>b[i]+c[i])stp=b[i]+c[i];
		for(j=0;j<n;j++){
			dp[i+1][j]=dp[i][j]+a[i]+b[i];
			if(dp[i+1][j]>dp[i][j+1]+a[i]+d[i])dp[i+1][j]=dp[i][j+1]+a[i]+d[i];
			if(j!=0&&dp[i+1][j]>dp[i][j-1]+b[i]+c[i])dp[i+1][j]=dp[i][j-1]+b[i]+c[i];
			if(j!=0&&dp[i+1][j]>dp[i][j]+c[i]+d[i])dp[i+1][j]=dp[i][j]+c[i]+d[i];
			if(j!=0&&dp[i+1][j]>dp[i+1][j-1]+stp)dp[i+1][j]=dp[i+1][j-1]+stp;
		}
		dp[i][n]=INF;
		for(j=0;j<n;j++){
			dp[i+1][j]+=m*(j*2+1);
		}
		stp+=2*m;
	}
	printf("%lld",dp[n][0]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 74996 KB Output is correct
2 Correct 0 ms 74996 KB Output is correct
3 Correct 0 ms 74996 KB Output is correct
4 Correct 0 ms 74996 KB Output is correct
5 Correct 0 ms 74996 KB Output is correct
6 Correct 0 ms 74996 KB Output is correct
7 Correct 0 ms 74996 KB Output is correct
8 Correct 0 ms 74996 KB Output is correct
9 Correct 0 ms 74996 KB Output is correct
10 Correct 0 ms 74996 KB Output is correct
11 Correct 0 ms 74996 KB Output is correct
12 Correct 0 ms 74996 KB Output is correct
13 Correct 0 ms 74996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 74996 KB Output is correct
2 Correct 0 ms 74996 KB Output is correct
3 Correct 0 ms 74996 KB Output is correct
4 Correct 0 ms 74996 KB Output is correct
5 Correct 0 ms 74996 KB Output is correct
6 Correct 0 ms 74996 KB Output is correct
7 Correct 0 ms 74996 KB Output is correct
8 Correct 0 ms 74996 KB Output is correct
9 Correct 0 ms 74996 KB Output is correct
10 Correct 0 ms 74996 KB Output is correct
11 Correct 0 ms 74996 KB Output is correct
12 Correct 0 ms 74996 KB Output is correct
13 Correct 0 ms 74996 KB Output is correct
14 Correct 0 ms 74996 KB Output is correct
15 Correct 0 ms 74996 KB Output is correct
16 Correct 0 ms 74996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 74996 KB Output is correct
2 Correct 0 ms 74996 KB Output is correct
3 Correct 64 ms 74996 KB Output is correct
4 Correct 60 ms 74996 KB Output is correct
5 Correct 48 ms 74996 KB Output is correct
6 Correct 20 ms 74996 KB Output is correct
7 Correct 8 ms 74996 KB Output is correct
8 Correct 64 ms 74996 KB Output is correct
9 Correct 60 ms 74996 KB Output is correct
10 Correct 76 ms 74996 KB Output is correct
11 Correct 60 ms 74996 KB Output is correct
12 Correct 64 ms 74996 KB Output is correct
13 Correct 48 ms 74996 KB Output is correct
14 Correct 84 ms 74996 KB Output is correct
15 Correct 64 ms 74996 KB Output is correct
16 Correct 68 ms 74996 KB Output is correct
17 Correct 56 ms 74996 KB Output is correct