33 lines
753 B
C++
33 lines
753 B
C++
#include <iostream>
|
|
using namespace std;
|
|
int main()
|
|
{
|
|
int n, k, a[501] = { 0 }, num[501] = { 0 }, sum = 0,f[501]={0},t=0,w=1,ans,now[501]={0};
|
|
cin >> n >> k;
|
|
for (int i = 1; i <= n; i++) {
|
|
cin >> a[i];
|
|
if (a[i] == 1) {
|
|
num[i] = ++sum;
|
|
}
|
|
}/*
|
|
now[1]=1;
|
|
do{
|
|
t++;
|
|
for(int i=now[t]+1;i<n;i++){
|
|
f[++w]=f[t]+(num[i]-num[now[t]-1])*num[i];
|
|
now[w]=i;
|
|
}
|
|
int bi=f[t]+(num[n]-num[now[t]-1])*num[n];
|
|
if(bi<sum){
|
|
sum=bi;
|
|
}
|
|
}while(t<w);*/
|
|
for(int i=1;i<=n;i++){
|
|
for(int j=1;j<=k;j++){
|
|
if(i==j){
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
cout<<sum;
|
|
} |