Pagini recente » Cod sursa (job #3185371) | Cod sursa (job #2635811) | Cod sursa (job #1814297) | Cod sursa (job #2614409) | Cod sursa (job #3269053)
#include <bits/stdc++.h>
using namespace std;
deque<int> d;
long long int n, k, v[5000001],s=0;
ifstream fin("deque.in");
ofstream fout("deque.out");
void citire(){
fin>>n>>k;
for(int i=1; i<=n; i++){
fin>>v[i];
}
}
void minim(){
long long mn=9999999;
for(int i=1; i<=n-k+1; i++){
mn=9999999;
for(int j=i; j<i+k; j++){
if(v[j]<mn){
mn=v[j];
}
}
s=(unsigned long long)s+mn;
}
}
/*void suma(){
while(!d.empty()){
s=(unsigned long long)s+d.front();
d.pop_front();
}
}*/
int main()
{
citire();
minim();
//suma();
fout<<s;
}