Cod sursa(job #540825)
| Utilizator | Data | 24 februarie 2011 14:40:29 | |
|---|---|---|---|
| Problema | Deque | Scor | 20 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.42 kb |
# include <cstdio>
# include <algorithm>
using namespace std;
int m, n, k, a[1000000], i, w;
long long s;
int main ()
{ freopen ("deque.in", "rt", stdin);
freopen ("deque.out", "wt", stdout);
scanf ("%d%d", &n, &k);
for (i = 1; i <= n; ++i) scanf ("%d", &a[i]);
for (w = 1; w <= n - k + 1; ++w)
{ m = *min_element(a + w, a + w + k);
s = s + m;
}
printf ("%lld\n", s);
}
