# bzoj3550 [ontak2010]vacation Simple Form __

Source: Internet
Author: User

Description

There are 3N number, you need to select some number, first of all, to ensure that any length of the interval of n, the number of selected <=k, and secondly to ensure that the number of the most selected.

Input

The first line is a two integer n,k.
The second row has a 3N integer.

Output

Sample Input

5 3

14 21 9 30, 11 8 1 20 29 23 17 27 7 8 35

Sample Output

195

HINT

"Data Range"

n<=200,k<=10.

Exercises
Bare-shaped problem.
Constructed according to the conditions.

Code

```#include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <
cmath> #include <set> #include <complex> #define LL long #define MOD 10000007 using namespace std;
inline int read () {int X=0,f=1;char ch=getchar (); while (ch< ' 0 ' | |
Ch> ' 9 ') {if (ch== '-') F=-1;ch=getchar ();}
while (ch>= ' 0 ' &&ch<= ' 9 ') {x=x*10+ch-' 0 '; Ch=getchar ();}
return x*f;
#define EPS (1e-10) const int n=1005;
int n,m,k;
Double A[n][n],b[n],c[n],ans;
inline void pivot (int l,int e) {b[l]/=a[l][e];
for (int i=1;i<=n;i++) if (i!=e) a[l][i]/=a[l][e];
A[l][e]=1.0/a[l][e];
for (int i=1;i<=m;i++) if (I!=l&&fabs (a[i][e)) >eps) {b[i]-=a[i][e]*b[l];
for (int j=1;j<=n;j++) if (j!=e) a[i][j]-=a[i][e]*a[l][j];
A[i][e]=-a[i][e]*a[l][e];
} Ans+=c[e]*b[l];
for (int i=1;i<=n;i++) if (i!=e) c[i]-=c[e]*a[l][i];
C[e]=-c[e]*a[l][e];
} void simplex () {int l,e;  while (1) {for (e=1;e<=n;e++) if (c[e]>eps) a break;
if (e==n+1) break;
Double t=10000000000;
for (int i=1;i<=m;i++) if (a[i][e]>eps&&b[i]/a[i][e]<t) {t=b[i]/a[i][e];
L=i;
} pivot (l,e);
int main () {scanf ("%d%d", &n,&k);
for (int i=1;i<=3*n;++i) scanf ("%lf", &c[i));
for (int i=1;i<=2*n+1;++i) {b[i]=k+0.0;
for (int j=i;j<=i+n-1;++j) a[i][j]=1.0;
for (int i=2*n+2;i<=5*n+1;++i) b[i]=1,a[i][i-2*n-1]=1;
m=5*n+1;n*=3;
Simplex ();
printf ("%.0LF", ans+eps);
return 0; }```
Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.