Cod sursa(job #2274407)
| Utilizator | Data | 1 noiembrie 2018 19:13:32 | |
|---|---|---|---|
| Problema | Branza | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <fstream>
using namespace std;
ifstream cin("branza.in");
ofstream cout("branza.out");
int v[100000],dq[100000];
int main()
{
long long n,s,t,p,suma=0;
cin>>n>>s>>t;
t++;
int st=0,dr=-1;
for(int i=0;i<n;i++){
cin>>v[i]>>p;
if(i>=t&&dq[st]==i-t){
st++;
}
while(st<=dr&&v[i]&&v[i]<=v[dq[dr]]+s*(i-dq[dr])){
dr--;
}
dq[++dr]=i;
suma+=p*(v[dq[st]]+s*(i-dq[st]));
}
cout<<suma;
return 0;
}
