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

贪心,维护上个月酸奶的成本

Posted by liu125008 at 2017-03-06 10:56:02 on Problem 2393
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int N,S,C[10005],Y[10005],pre;
long long sum;
int main()
{
    scanf("%d%d",&N,&S);
    for(int i=1;i<=N;i++)
        scanf("%d%d",&C[i],&Y[i]);
    pre=C[1];
    sum+=(pre*Y[1]);
    for(int i=2;i<=N;i++)
    {
        pre=(C[i]<=pre+S)?C[i]:pre+S;
        sum+=(pre*Y[i]);
    }
    printf("%lld",sum);
    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