Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
dg-029 authored Sep 27, 2020
1 parent 9224734 commit a6a79be
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions 363B.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <iostream>
#include<cmath>
using namespace std;

int main() {
int n,k;
cin>>n>>k;
long long arr[n+8]={0};
// input + cumlative sum
for(int i=0;i<n;i++){
cin>>arr[i];
if(i){
arr[i]=arr[i-1]+arr[i];
}
}


int min=150000010;
long long minindex=0;
for(int i=0;i<=n-k;i++){
long long sum=0;
if(!i){
sum=arr[i+k-1];
if(sum<=min){
min=sum;
minindex=i;
}

}
else {
sum=arr[i+k-1]-arr[i-1];

if(sum<=min){
min=sum;
minindex=i;
}
}


}
cout<<++minindex<<endl;
return 0;
}

0 comments on commit a6a79be

Please sign in to comment.