Submission #6876

#TimeUsernameProblemLanguageResultExecution timeMemory
6876gs12117도장 모으기 (JOI14_stamps)C++98
85 / 100
0 ms5780 KiB
#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+1]+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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...