Cod sursa(job #2281502)
| Utilizator | Data | 12 noiembrie 2018 13:18:47 | |
|---|---|---|---|
| Problema | Deque | Scor | 20 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("deque.in");
ofstream g("deque.out");
int n,k,x,s=0;
vector <int> V,Q;
int main()
{
f>>n>>k;
for(int i=1; i<=k; i++)
{
f>>x;
V.push_back(x);
}
Q=V;
sort(Q.begin(),Q.end());
s+=Q[0];
for(int i=k+1; i<=n; i++)
{
f>>x;
V.push_back(x);
V.erase(V.begin());
Q=V;
sort(Q.begin(),Q.end());
s+=Q[0];
}
g<<s;
return 0;
}
