Cod sursa(job #2732137)
| Utilizator | Data | 28 martie 2021 19:19:11 | |
|---|---|---|---|
| Problema | Branza | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.6 kb |
#include <iostream>
#include<fstream>
#include<deque>
using namespace std;
ifstream f("branza.in");
ofstream g("branza.out");
deque<int> d;
int main()
{
long long n,s,t,p,c[100010], pret = 0;
f>>n>>s>>t;
t++;
for(int i =0; i<n;i++)
{
f>>c[i]>>p;
if(d.size() != 0 && d.front() == i-t)
d.pop_front();
while(d.size() != 0 && c[i] <= c[d.back()]+ s* (i - d.back()))
d.pop_back();
d.push_back(i);
pret += (long long)p * (c[d.front()] + s* (i - d.front()));
}
g<<pret;
return 0;
}
