Cod sursa(job #2731478)
| Utilizator | Data | 27 martie 2021 20:42:19 | |
|---|---|---|---|
| Problema | Deque | Scor | 20 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.53 kb |
#include <iostream>
#include <fstream>
using namespace std;
int l[5000001];
int main()
{
ifstream f("deque.in");
ofstream g("deque.out");
int n, k;
long long s =0;
f>>n>>k;
for (int c = 1; c <= n; c++)
{
f >> l[c];
}
int d = 1;
while (k <= n)
{
int min = l[d];
for (int c = d + 1; c <= k; c++)
{
if (min >= l[c])
{
min = l[c];
}
}
k++;
d++;
s += min;
}
g<<s;
return 0;
}