Cod sursa(job #2545202)
| Utilizator | Data | 12 februarie 2020 21:31:01 | |
|---|---|---|---|
| Problema | Branza | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("branza.in");
ofstream g("branza.out");
deque <long long> q;
long long n,S,t,i,min_val,cant,suma,cost[100100];
int main()
{
f>>n>>S>>t;
for(i=1;i<=n;i++)
{
f>>cost[i]>>cant;
while(!q.empty() && cost[i]<=(cost[q.back()]+S*(i-q.back())))q.pop_back();
q.push_back(i);
while(i-q.front()>t)q.pop_front();
min_val=cost[q.front()]+S*(i-q.front());
suma+=min_val*cant;
}
g<<suma;
return 0;
}
