QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#587121#5303. No Bug No Gamewsxcb#WA 296ms3860kbC++17903b2024-09-24 17:42:022024-09-24 17:42:03

Judging History

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

  • [2024-09-24 17:42:03]
  • 评测
  • 测评结果:WA
  • 用时:296ms
  • 内存:3860kb
  • [2024-09-24 17:42:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int INF=1e18;
using ll = long long;
void solve(){
	
	int n , k; cin >> n >> k;
	
	vector<vector<ll>> f(k + 10 , vector<ll>(2 , 0));
	for(int i = 1 ; i <= n ; i++){
		int p; cin >> p;
		vector<int> w(p + 1);
		for(int j = 1 ; j <= p ; j++) cin >> w[j];
		
		auto dp = f;
		for(int j = k ; j >= 0 ; j--){
			if(j + p <= k){
				dp[j + p][0] = max(dp[j + p][0] , max(f[j][0] , f[j][1]) + w[p]);
			//	dp[j + p][1] = max(dp[j + p][1] , f[j][0] + w[p]);
			}
			for(int q = 1 ; q < p && q + j <= k ; q++){
				dp[j + q][1] = max(dp[j + q][1] , f[j][0] + w[q]);
			}
		}	
		f.swap(dp);
	}
	
	ll mx = 0;
	for(int i = 0 ; i <= k ; i++){
		mx = max({mx , f[i][0] , f[i][1]});
	}
	cout << mx << '\n';
	
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int T = 1;
	while(T--){
		solve();
	}
	
	return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3600kb

input:

4 5
2 1 3
2 1 1
2 3 1
2 1 3

output:

9

result:

ok 1 number(s): "9"

Test #2:

score: -100
Wrong Answer
time: 296ms
memory: 3860kb

input:

3000 3000
10 70562 30723 79371 82224 63977 3362 26909 96449 48163 66159
4 18007 33590 80674 91139
4 10304 31694 70745 50656
10 63090 17226 13187 73881 38137 15237 55750 82751 75854 39658
8 95640 66120 87735 36388 44046 92415 6952 94772
9 60565 27904 98726 87052 35768 25453 14563 34273 92501
10 66332...

output:

114175400

result:

wrong answer 1st numbers differ - expected: '68279788', found: '114175400'