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

Re:给你们一个出测试数据的程序吧,运行一下就输入数据输出数据都出来了,如果全对,你的程序没过找我,数据太多,你们可以写个文件比对程序

Posted by shuaqqq at 2013-07-24 17:11:35 on Problem 1036
In Reply To:给你们一个出测试数据的程序吧,运行一下就输入数据输出数据都出来了,如果全对,你的程序没过找我,数据太多,你们可以写个文件比对程序 Posted by:HH_YT at 2012-08-15 10:38:48
我来找你了, 我还真对比了没差距但是我的代码就是过不了,怎么破
附代码
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct X{
	int t,p,s;
}x[150];
int dp[2][105];
bool cmp(X a,X b)
{
	return a.t<b.t;
}
int main()
{
	int n,k,t;
		freopen("input.txt", "r", stdin);
	freopen("123.txt","w", stdout);
	while(scanf("%d%d%d",&n,&k,&t)!=EOF)
	{
		int i,j,sb,q;
		for(i=0;i<n;i++)
			scanf("%d",&x[i].t);
		for(i=0;i<n;i++)
			scanf("%d",&x[i].p);
		for(i=0;i<n;i++)
			scanf("%d",&x[i].s);
		sort(x,x+n,cmp);
		memset(dp,0,sizeof(dp));
		for(i=0,q=0,sb=0;i<=t;sb=1-sb,i++)
		{
			for(j=0;j<=i&&j<=k;j++)
			{
				dp[sb][j]=dp[1-sb][j];
				if(j-1>=0)
					dp[sb][j]=dp[sb][j]>dp[1-sb][j-1]?dp[sb][j]:dp[1-sb][j-1];
				if(j+1<=k)
					dp[sb][j]=dp[sb][j]>dp[1-sb][j+1]?dp[sb][j]:dp[1-sb][j+1];
			}
			while(q<n&&x[q].t==i)
			{
				if(x[q].s<j)
					dp[sb][x[q].s]+=x[q++].p;
				else
					q++;
			}
			//for(j=0;j<=k;j++)
			//	printf("%d ",dp[sb][j]);
			//printf("\n");
		}
		int max=0;
		for(j=0;j<=k;j++)
		{
			if(dp[1-sb][j]>max)
				max=dp[1-sb][j];
		}
		printf("%d\n",max);
	}
	return 0;
}

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