题意
一条直线上有N个村庄,要在这条直线上选K个地方建雕像,使得每个村庄到离其最近的雕像的距离的和最小。输出最小的和。
题解
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string.h>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<vector>
using namespace std;
typedef long long int ll;
const int maxn =1e9+5;
const int maxm=10000;
const int mod =1e9+7;
const int INF=0x3f3f3f3f;
const double eps=1e-8;
const int MAXN=3e5+10;
struct node
{
int l,r,p;
node(){}
node(int _l,int _r,int _p):l(_l),r(_r),p(_p){}
};
node que[MAXN];
int n,k,a[MAXN],num[