Mai intai trebuie sa te autentifici.
Cod sursa(job #2378874)
Utilizator | Data | 12 martie 2019 18:19:05 | |
---|---|---|---|
Problema | Branza | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("branza.in");
ofstream g("branza.out");
deque <int> v;
long long cost,c[100001];
int main()
{
long long n,s,t,p,i,j;
f>>n>>s>>t;
for(i=1;i<=n;++i){
f>>c[i]>>p;
while(!v.empty() && c[v.back()]+s*(i-v.back())>c[i])
v.pop_back();
while(!v.empty() && i-v.front()>t)
v.pop_front();
v.push_back(i);
cost+=(c[v.front()]+s*(i-v.front()))*p;
}
g<<cost;
return 0;
}