Cod sursa(job #2732126)
Utilizator | Burdusa Petru petru.burdusa | Data | 28 martie 2021 19:09:31 |
---|---|---|---|
Problema | Branza | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <iostream>
#include <fstream>
#include<deque>
using namespace std;
int n,s,t,i,c[100005],p;
long long rez;
deque<int>d;
int main() {
ifstream in("branza.in");
ofstream out("branza.out");
in>>n>>s>>t;
for(i=1;i<=n;i++)
{
in>>c[i]>>p;
while(!d.empty() && c[i] < c[d.front()] + (i-d.front())*s)
d.pop_front();
while(!d.empty() && d.front() < i-t)
d.pop_front();
d.push_back(i);
rez += p * (c[d.front()] + (i-d.front()) * s);
}
out<<rez;
}