QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#41302#4412. Boss RushDaBenZhongXiaSongKuaiDi#RE 0ms0kbC++141.3kb2022-07-29 14:09:202022-07-29 14:09:21

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-29 14:09:21]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2022-07-29 14:09:20]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
	int n=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		n=n*10+ch-'0';
		ch=getchar();
	}
	return n*f;
}
int lq[105],len[105];
vector<int>d[105];
int dp[1000005];
int zh[1000005];
signed main()
{
	int t,n,h,l,r,mid,x;
	t=read();
	for(int greg=1;greg<=t;greg++)
	{
		n=read();
		h=read();
		l=1;
		r=1000000000;
		for(int i=1;i<=n;i++)
		{
			lq[i]=read();
			len[i]=read();
			d[i].clear();
			x=0;
			for(int j=0;j<len[i];j++)
			{
				x+=read();
				d[i].push_back(x);
			}
		}
		for(int i=1;i<(1<<n);i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(i&(1<<(j-1)))
				{
					zh[i]=zh[i-(1<<(j-1))]+lq[i];
				}
			}
		}
		while(l<=r)
		{
			mid=(l+r)>>1;
			dp[0]=0;
			for(int i=1;i<(1<<n);i++)
			{
				dp[i]=0;
				for(int j=1;j<=n;j++)
				{
					if((i&(1<<(j-1)))==0)continue;
					if(mid-zh[i-(1<<(j-1))]>=0)dp[i]=max(dp[i],dp[i-(1<<(j-1))]+d[j][min(mid-zh[i-(1<<(j-1))],len[j]-1)]);
					else dp[i]=max(dp[i],dp[i-(1<<j-1)]);
				}
			}
			//printf("%lld %lld\n",mid,dp[(1<<n)-1]);
			if(dp[(1<<n)-1]>=h)r=mid-1;
			else l=mid+1;
		}
		if(l>1000000000)printf("-1\n");
		else printf("%lld\n",l);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

100
10 293367178351
89 52
117480172 951737726 356435682 180765874 775623083 281703307 290364363 366421773 989361116 796791408 389709469 534380525 412173405 463001602 578985383 272777986 833157533 444367936 841474617 472532665 952319800 583679381 924952511 892974994 105808118 171375863 320943603 4870...

output:


result: