This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n,m,i,t[1001],kq,d[1001];
void vet(int i,int sl)
{
if(sl>m) return ;
if(i>n)
{
int sum=0,vt;
for(int j=1;j<=n;j++)
{
if(d[j]==1) vt=t[j];
if(j==n || d[j+1]==1) sum+=t[j]+1-vt;
}
kq=min(kq,sum);
return ;
}
if(i==1) { d[i]=1; vet(i+1,sl+1); }
else
{
for(int j=0;j<=1;j++)
{
d[i]=j;
vet(i+1,sl+j);
}
}
}
void sub1()
{
kq=round(1e9);
vet(1,0);
cout<<kq;
}
int main()
{
//freopen("stove.inp","r",stdin);
//freopen("stove.out","w",stdout);
cin>>n>>m;
for(i=1;i<=n;i++) cin>>t[i];
sub1();
}
Compilation message (stderr)
stove.cpp: In function 'void vet(int, int)':
stove.cpp:13:46: warning: 'vt' may be used uninitialized in this function [-Wmaybe-uninitialized]
if(j==n || d[j+1]==1) sum+=t[j]+1-vt;
~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |