问题
https://vjudge.net/problem/UVA-662
分析
和上一题UVA607很像,记录一下最优解的状态就行了,另外 区间【l,r】之间的最优点是(l+r)/2,这一点画图就可以看出来
代码
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;
const int maxn=200+5,Inf=0x3f3f3f3f;
struct State{
int cost,l,r;
State(int cost=0,int l=0,int r=0):cost(cost),l(l),r(r){
}
};
//仓库位于它负责的餐馆中间,如果是偶数,那么任意一个都可以
//dp[i][j]表示前i个仓库为前j个餐馆提供服务的累计最小代价
int n,k,d[maxn