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 |
50题留念,还有很长的路要走#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator