Cod sursa(job #2164899)
Utilizator | Data | 13 martie 2018 10:21:32 | |
---|---|---|---|
Problema | Deque | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.53 kb |
#include<fstream>
using namespace std;
ifstream f("deque.in");
ofstream g("deque.out");
int n,k,inceput,sfarsit,q[5000001],mi,i,x,j;
long long s;
int main()
{
f>>n>>k;
inceput=1;
for(i=1;i<=n;i++)
{
f>>x;
q[++sfarsit]=x;
if(sfarsit-inceput==k-1)
{
mi=1000001;
for(j=inceput;j<=sfarsit;j++)
{
if(mi>q[j])
mi=q[j];
}
s+=mi;
inceput++;
}
}
g<<s;
return 0;
}