zoukankan      html  css  js  c++  java
  • BZOJ 4244: 邮戳拉力赛

    转化为括号序列DP

    注意边界

    #include<cstdio>
    #include<algorithm>
    #define rep(i,x,y) for (int i=x; i<=y; i++)
    using namespace std;
    long long F[3005][3005];
    int main(){
    	int n,T;
    	scanf("%d%d",&n,&T);
    	rep(i,0,n) rep(j,0,n+1) F[i][j]=1ll<<60;
    	F[0][0]=0;
    	for (int i=1; i<=n; i++){
    		int u,v,d,e;
    		scanf("%d%d%d%d",&u,&v,&d,&e);
    		for (int j=0; j<=n; j++) F[i][j]=min(F[i][j],F[i-1][j]+u+v);
    		for (int j=1; j<=n; j++) F[i][j]=min(F[i][j],F[i-1][j]+e+d);
    		for (int j=1; j<=n; j++) F[i][j]=min(F[i][j],F[i-1][j-1]+d+v);
    		for (int j=0; j<=n; j++) F[i][j]=min(F[i][j],F[i-1][j+1]+u+e);
    		for (int j=1; j<=n; j++) F[i][j]=min(F[i][j],F[i][j-1]+d+v);
    		for (int j=n; j>=0; j--) F[i][j]=min(F[i][j],F[i][j+1]+u+e);
    		for (int j=0; j<=n; j++) F[i][j]+=2*j*T;
    	}
    	printf("%lld
    ",F[n][0]+(n+1)*T);
    	return 0;
    }
    

      

  • 相关阅读:
    集群资源队列监控:Grafana
    1
    3月9号
    jmx
    日常笔记
    nsenter命令简介
    一天2小时
    postgresql Centos7部署
    笔记5
    1
  • 原文地址:https://www.cnblogs.com/silenty/p/9858757.html
Copyright © 2011-2022 走看看