Cod sursa(job #1046692)
| Utilizator | Data | 3 decembrie 2013 12:50:14 | |
|---|---|---|---|
| Problema | Deque | Scor | 20 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
ifstream f("deque.in");
ofstream g("deque.out");
long long v[5000002], n, k, s;
vector<int> h;
int main()
{
f>>n>>k;
for(int i=0; i<n; ++i)
f>>v[i];
for(int i=0; i<n-k+1; ++i){
for(int j=i; j<i+k; ++j)
h.push_back(-v[j]);
make_heap(h.begin(), h.end());
s+=-h.front();
h.clear();
}
g<<s;
return 0;
}
