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:adam123 at 2007-07-17 13:29:17 #include <cstdio> #define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++) int m , p , vp[303] , vk[303] , dp[303] , cp[303],pyhawys11; int main(){ scanf("%d %d",&m,&p); ffor(i,1,p+1) scanf("%d %d",vp+i,vk+i); dp[0]=1; cp[0] = vp[0] = vk[0] = 0; int f,k,j,s; ffor(i,1,p+1){ dp[i]=1000000000; f=vp[i],k=vk[i]; for(j=i-1; j>=0 && f<=m && k<=m;--j){ s = dp[j]+2-(cp[j]<=m-f); if (s<dp[i] || (s==dp[i] && cp[i]>k)) dp[i]=s , cp[i]=k; f += vp[j]; k += vk[j]; } } printf("%d\n",dp[p]+1); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator