Submission #6877

# Submission time Handle Problem Language Result Execution time Memory
6877 2014-07-08T17:24:46 Z gs12117 도장 모으기 (JOI14_stamps) C++
85 / 100
0 ms 5780 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 dpa[100100];
long long int dpb[100100];
long long int stp;
int main(){
	int i;
	scanf("%d%lld",&n,&m);
	dpa[0]=m;
	dpb[0]=INF;
	stp=INF;
	for(i=0;i<n;i++){
		scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
		if(stp>b[i]+c[i])stp=b[i]+c[i];
		dpa[i+1]=dpa[i]+a[i]+b[i];
		dpb[i+1]=dpb[i]+a[i]+b[i];
		if(dpb[i+1]>dpb[i]+c[i]+d[i])dpb[i+1]=dpb[i]+c[i]+d[i];
		if(dpa[i+1]>dpb[i]+a[i]+d[i])dpa[i+1]=dpb[i]+a[i]+d[i];
		if(dpb[i+1]>dpa[i]+b[i]+c[i])dpb[i+1]=dpa[i]+b[i]+c[i];
		if(dpb[i+1]>dpa[i]+stp+c[i]+d[i])dpb[i+1]=dpa[i]+stp+c[i]+d[i];
		if(dpb[i+1]>dpa[i+1]+stp)dpb[i+1]=dpa[i+1]+stp;
		dpa[i+1]+=m;
		dpb[i+1]+=3*m;
		stp+=2*m;
	}
	printf("%lld",dpa[n]);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5780 KB Output is correct
2 Correct 0 ms 5780 KB Output is correct
3 Correct 0 ms 5780 KB Output is correct
4 Correct 0 ms 5780 KB Output is correct
5 Correct 0 ms 5780 KB Output is correct
6 Correct 0 ms 5780 KB Output is correct
7 Correct 0 ms 5780 KB Output is correct
8 Correct 0 ms 5780 KB Output is correct
9 Correct 0 ms 5780 KB Output is correct
10 Correct 0 ms 5780 KB Output is correct
11 Correct 0 ms 5780 KB Output is correct
12 Correct 0 ms 5780 KB Output is correct
13 Correct 0 ms 5780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5780 KB Output is correct
2 Correct 0 ms 5780 KB Output is correct
3 Correct 0 ms 5780 KB Output is correct
4 Correct 0 ms 5780 KB Output is correct
5 Correct 0 ms 5780 KB Output is correct
6 Correct 0 ms 5780 KB Output is correct
7 Correct 0 ms 5780 KB Output is correct
8 Correct 0 ms 5780 KB Output is correct
9 Correct 0 ms 5780 KB Output is correct
10 Correct 0 ms 5780 KB Output is correct
11 Correct 0 ms 5780 KB Output is correct
12 Correct 0 ms 5780 KB Output is correct
13 Correct 0 ms 5780 KB Output is correct
14 Correct 0 ms 5780 KB Output is correct
15 Correct 0 ms 5780 KB Output is correct
16 Correct 0 ms 5780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5780 KB Output is correct
2 Correct 0 ms 5780 KB Output is correct
3 Correct 0 ms 5780 KB Output is correct
4 Correct 0 ms 5780 KB Output is correct
5 Correct 0 ms 5780 KB Output is correct
6 Incorrect 0 ms 5780 KB Output isn't correct
7 Halted 0 ms 0 KB -