Cod sursa(job #2528658)
Utilizator | Data | 22 ianuarie 2020 12:16:30 | |
---|---|---|---|
Problema | Branza | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.6 kb |
#include <fstream>
#include <deque>
using namespace std;
ifstream f("branza.in");
ofstream g("branza.out");
int n, s, t, ans;
struct week {
int pos, cost;
};
deque <week> v;
int main()
{
f >> n >> s >> t;
for (int i = 1; i <= n; ++i) {
int c, p;
f >> c >> p;
if (i > t && v.front().pos < i - t)
v.pop_front();
while (v.back().cost + (i - v.back().pos) * s > c)
v.pop_back();
v.push_back({i, c});
ans += p*v.front().cost + (i - v.front().pos) * s;
}
g << ans;
return 0;
}