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 |
贪心,维护上个月酸奶的成本#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator