Cod sursa(job #2623929)
| Utilizator | Data | 4 iunie 2020 10:28:08 | |
|---|---|---|---|
| Problema | Branza | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.59 kb |
#include <fstream>
#include <deque>
#define NMAX 100005
using namespace std;
ifstream f("branza.in");
ofstream g("branza.out");
long long n, s, t;
long long pmin;
deque<long long> D;
long long c[NMAX], p[NMAX];
int main()
{
f>>n>>s>>t;
for(int i=0; i<n; i++){
f>>c[i]>>p[i];
while(!D.empty() && c[D.back()] + (i-D.back())*s >= c[i])
D.pop_back();
while(!D.empty() && (i-D.front())>t)
D.pop_front();
D.push_back(i);
pmin = pmin+c[D.front()]*p[i] + p[i]*(i-D.front())*s;
}
g<<pmin;
return 0;
}
