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 |
我和你思想一样,你的AC?我却TLEIn Reply To:我说不清楚了,贴一下关键的部分吧,现在对DP一点感觉都没有了,状态都不会设计了 Posted by:frkstyc at 2005-04-17 19:35:34 > qsort(b + 1, N, sizeof(BLOCK), comp); // 按a_i排序 > for(i = 1; i <= N; i++) > { > int m = 0; > memset(p2, 0, sizeof(p2)); // hash当前的和 > for(j = 0; j < n; j++) > { > int h = p1[j]; // 上一个的第j个和 > int c = min((b[i].a - h) / b[i].h, b[i].c); > if(c < 0) > { > break; // j个放不下j+1个更不可能 > } > for(k = 0; k <= c; k++) > { > p2[h] = 1; // hash记录 > h += b[i].h; > } > c = h - b[i].h; > if(c > m) > { > m = c; // 更新当前的最大 > } > } > n = 0; > for(j = 0; j <= m; j++) > { > if(p2[j] != 0) > { > p1[n] = j; // 把hash做成一般的表 > n++; > } > } > if(p1[n - 1] > M) > { > M = p1[n - 1]; // 更新全局最大 > } > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator