Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

我和你思想一样,你的AC?我却TLE

Posted by direfire at 2006-10-27 17:22:54 on Problem 2392
In 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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator