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

50题留念,还有很长的路要走

Posted by lvweihua at 2017-08-09 20:42:02 on Problem 2393
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=10005;
int C[MAXN],Y[MAXN],N,S;
long long sum=0;
void solve(){
    long long sum=C[0]*Y[0];
    for(int i=1;i<N;i++)
        C[i]=min(C[i-1]+S,C[i]);
    for(int i=1;i<N;i++)
        sum+=C[i]*Y[i];
    printf("%lld\n",sum);
}
int main()
{
    while(scanf("%d%d",&N,&S)!=EOF){
        memset(C,0,sizeof(C));
        memset(Y,0,sizeof(Y));
        for(int i=0;i<N;i++)
            scanf("%d%d",&C[i],&Y[i]);
        solve();
    }
    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