Cod sursa(job #2366346)
| Utilizator | Data | 4 martie 2019 19:40:56 | |
|---|---|---|---|
| Problema | Branza | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <bits/stdc++.h>
using namespace std;
int c[100010];
deque<int>d;
int n,s,t,i,x,y;
long long total;
int main()
{
freopen("branza.in","r",stdin);
freopen("branza.out","w",stdout);
scanf("%d%d%d",&n,&s,&t);
for (i=1;i<=n;i++){
scanf("%d%d",&x,&y);
c[i]=x;
while (!d.empty()&&(c[d.back()]+s*(i-d.back())>c[i])) d.pop_back();
d.push_back(i);
while (i-d.front()>t&&!d.empty()) d.pop_front();
total+=1LL*(c[d.front()]+s*(i-d.front()))*y;
}
printf("%lld",total);
return 0;
}
