UVA 1336 Fixing the Great Wall - ACM/ICPC CERC 2004

#include<bits/stdc++.h>
using namespace std;
double v,kase,vis[1010][1010][2],f[1010][1010][2];
int n;
struct node{
	double l,tt,pl;
}a[1010];
double add(int i,int j){
	return a[j].l-a[i-1].l;
}
int cmp(node q,node p){
	return q.pl<p.pl;
}
double dp(int i,int j,int k){
	if(vis[i][j][k]==kase)return f[i][j][k];
	if(i==1&&j==n)return 0;
	double sum=add(1,i-1)+add(j+1,n),ans=1e9;
	if(k==0){
		if(i!=1)ans=min(ans,dp(i-1,j,0)+(a[i].pl-a[i-1].pl)/v*sum);
		if(j!=n)ans=min(ans,dp(i,j+1,1)+(a[j+1].pl-a[i].pl)/v*sum);
	}
	else{
		if(i!=1)ans=min(ans,dp(i-1,j,0)+(a[j].pl-a[i-1].pl)/v*sum);
		if(j!=n)ans=min(ans,dp(i,j+1,1)+(a[j+1].pl-a[j].pl)/v*sum);
	}
	vis[i][j][k]=kase;
	f[i][j][k]=ans;
	return ans;
}
int main(){
	int i,t1,t2;
	double x,c,sum,ans;
	while(~scanf("%d%lf%lf",&n,&v,&x)&&(n+v+x)){
		kase++;
		sum=0;
		for(i=1;i<=n;i++){
			scanf("%lf%lf%lf",&a[i].pl,&c,&a[i].tt);
			sum+=c;
		}
		sort(a+1,a+1+n,cmp);
		a[0].l=0;
		for(i=1;i<=n;i++)
			a[i].l=a[i-1].l+a[i].tt;
		a[0].pl=-1;
		a[n+1].pl=1e9;
		for(i=1;i<=n+1;i++)
			if(a[i].pl>x&&a[i-1].pl<x){
				t1=i-1;
				t2=i;
			}
		ans=1e9;
		if(t1!=0)ans=min(ans,dp(t1,t1,0)+(x-a[t1].pl)/v*add(1,n));
		if(t2!=n+1)ans=min(ans,dp(t2,t2,0)+(a[t2].pl-x)/v*add(1,n));
		printf("%.lf\n",floor(ans+sum));
	}
	return 0;
}

I'm sorry to hear that you're encountering an error with the dpkg command. The "Sub-process /usr/bin/dpkg returned an error code" usually indicates an issue with the package management system on your system. Here are a few steps you can try to resolve this issue: 1. Check for broken dependencies: Run the following command to check if there are any broken dependencies: ```bash sudo apt-get check ``` If any broken dependencies are found, you can try fixing them by running: ```bash sudo apt-get install -f ``` 2. Clear the package cache: Sometimes, issues can arise due to a corrupt or incomplete package cache. You can try clearing the package cache and then reconfiguring dpkg by running the following commands: ```bash sudo apt-get clean sudo apt-get autoclean sudo apt-get update sudo dpkg --configure -a ``` 3. Remove conflicting packages: If the issue persists, it's possible that there are conflicting packages on your system. You can try removing any conflicting packages by running: ```bash sudo dpkg --remove <package-name> ``` Replace `<package-name>` with the name of the package causing the error. 4. Force package installation or removal: If the above steps don't work, you can try forcing the installation or removal of a package using the `--force` flag. However, be cautious when using this option, as it may lead to inconsistencies in your system. For example: ```bash sudo dpkg --force-all -i <package-name>.deb ``` Replace `<package-name>.deb` with the name of the package you want to install. If none of these solutions work, please provide more details about the error message or any other relevant information, and I'll do my best to assist you further.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值