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 |
Re:都按着解题报告写啦...为什么还wa呢??一百个不理解...In Reply To:都按着解题报告写啦...为什么还wa呢??一百个不理解... Posted by:yuanyirui at 2007-05-12 00:01:16 我的DP也过不去 #include <cstdio> #include <algorithm> using namespace std; int dp=0; int ManWork[16001]={0}; int S[100]={0}; int P[100]={0}; int L[100]={0}; int main() { int fenceNum,workNum,ans=0; while(scanf("%d %d",&fenceNum,&workNum)!=EOF) { for(int i=0;i<workNum;i++) { scanf("%d %d %d",&L[i],&P[i],&S[i]); } for(int i=0;i<workNum;i++) { int iEnd = S[i]+L[i]-1;//工人在的位置 int iStart = S[i]; int pay = P[i]; for(;iEnd>=S[i];) { dp = max(ManWork[iStart-1],dp-pay); if(dp<0) dp = 0; if(iStart<1) { iStart = 1; } if(dp+(iEnd-iStart+1)*pay>ManWork[iEnd]) ManWork[iEnd] = dp+(iEnd-iStart+1)*pay; if(ans<ManWork[iEnd]) { ans = ManWork[iEnd]; } iEnd--; iStart = iEnd-L[i]+1; } } printf("%d\n",ans); dp=0; memset(ManWork,0,sizeof(int)*(fenceNum+1)); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator