Cod sursa(job #2889425)
| Utilizator | Data | 12 aprilie 2022 19:17:15 | |
|---|---|---|---|
| Problema | Branza | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.56 kb |
#include <bits/stdc++.h>
#define LL long long
using namespace std;
ifstream fin("branza.in");
ofstream fout("branza.out");
LL n,s,t,cost,cant,minn;
deque<pair<LL,LL>> dq;
int main() {
fin>>n>>s>>t;
for(int i=0;i<n;i++){
fin>>cost>>cant;
while(!dq.empty() && cost <= dq.back().second + s*(i-dq.back().first))
dq.pop_back();
dq.push_back(make_pair(i,cost));
if(dq.front().first < i-t)
dq.pop_front();
minn += cant*(dq.front().second + s * (i-dq.front().first));
}
fout<<minn;
return 0;
}