Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

简单dp 1Y

Posted by pigengen at 2011-03-13 17:12:01 on Problem 2393
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator