Pagini recente » Cod sursa (job #379882) | Cod sursa (job #385486) | Cod sursa (job #2713036) | Cod sursa (job #2064132) | Cod sursa (job #1002657)
#include <cstdio>
struct client{
int timp, pret;
} cl[2010];
int main()
{
freopen("carnati.in","r",stdin);
freopen("carnati.out","w",stdout);
int n,c;
scanf("%d%d",&n,&c);
for(int i=1;i<=n;i++)
scanf("%d%d",&cl[i].timp,&cl[i].pret);
long long cost,max=0;
for(int h=1;h<=n;h++)
{
cost=cl[h].pret;
long long act=0;
for(int i=1;i<=n;i++)
{
act=act-c*(cl[i].timp-cl[i-1].timp);
if(cl[i].pret>=cost)
{
if(act+cost>cost)
{
act+=cost;
}
else
act=cost;
if(act>max)
{
max=act;
}
}
}
}
printf("%lld",max-c);
return 0;
}