QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#93918#4412. Boss Rushkatoli#RE 0ms0kbC++141.1kb2023-04-03 22:28:172023-04-03 22:28:21

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-03 22:28:21]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-04-03 22:28:17]
  • 提交

answer

#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
using ll=long long;

const int N=1e5+5;
ll pre[20][N];
int t[20],len[20];
int n;
ll cal(int T){
	vector<ll>dp(1<<n,-1);
	dp[0]=0;
	ll res=0;
	for(int S=1;S<1<<n;++S){
		int tot=0;
		for(int i=0;i<n;++i){
			if(S>>i&1)tot+=t[i];
		}
		for(int i=0;i<n;++i){
			if(S>>i&1){
				int la=S^(1<<i);
				if(dp[la]==-1)continue;
				int til=min(len[i]-1,T-(tot-t[i]));
				dp[S]=max(dp[S],dp[la]+pre[i][til]);
			}
		}
		res=max(res,dp[S]);
	}
	return res;
}
signed main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int T;cin>>T;
	for(;T;T--){
		cin>>n;
		ll h;cin>>h;
		for(int i=0;i<n;++i){
			cin>>t[i]>>len[i];
			for(int j=0;j<len[i];++j){
				cin>>pre[i][j];
				if(j)pre[i][j]+=pre[i][j-1];
			}
		}
		int l=0,r=2e6,ans=-1;
		for(;l<=r;){
			int m=(l+r)>>1;
			if(cal(m)>=h)r=m-1,ans=m;
			else l=m+1;
		}
		cout<<ans<<endl;
	}
	return 0;
}
// init?
// var->0?
// infinite dfs?
// out of bound?
// max_element / min_element?

詳細信息

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: