| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
简单dp 1Y#include<stdio.h>
#include<iostream>
using namespace std;
__int64 ans;
int n,s;
struct node
{
int value;
int quantity;
};
node a[10010];
int main()
{
while(scanf("%d%d",&n,&s)!=EOF)
{
for(int i=1;i<=n;i++)
{
scanf("%d%d",&a[i].value,&a[i].quantity);
}
ans=a[1].value*a[1].quantity;
for(int i=2;i<=n;i++)
{
if(a[i-1].value+s<a[i].value)
a[i].value=a[i-1].value+s;
ans+=a[i].value*a[i].quantity;
}
printf("%I64d\n",ans);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator