363B-Fence

#include<bits/stdc++.h>
using namespace std;
int main()
{int n,h,k;
cin>>n>>k;
int a[n+1];
int s=1;
int c=0;
int sum=0;
for(int i=1;i<=n;i++)
cin>>a[i];
int mn = 100000;
 int i=1;
 while(1){
if(k>=n)break;
cout<<i<<" "<<k<<endl;
 sum=0;
 for(int j=i;j<=k;j++)
 sum=sum+a[j];

mn = min(sum,mn);
i++;
k++;


 }
cout<<mn;
}

Comments

Popular posts from this blog

Codeforce Problem 1703A. YES or YES?

Aptitude test assistant programmer 2018

1041A. Heist solution