QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#587184#5303. No Bug No Gamewsxcb#WA 0ms3604kbC++171.3kb2024-09-24 18:02:272024-09-24 18:02:28

Judging History

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

  • [2024-09-24 18:02:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3604kb
  • [2024-09-24 18:02:27]
  • 提交

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<vector<ll>>> f(n + 1 , vector<vector<ll>>(k + 10 , vector<ll>(2)));
	vector<int>p (n + 1);
	vector<vector<int>> w(n + 1 , vector<int>(20));
	
	for(int i = 1 ; i <= n ; i++){
		cin >> p[i];
		for(int j = 1 ; j <= p[i] ; j++){
			cin >> w[i][j];
		}
	}
	
	cout << '\n';
	for(int i = 1 ; i <= n ; i++){
		for(int j = k ; j >= 0 ; j--){
			f[i][j][0] = f[i - 1][j][0] , f[i][j][1] = f[i - 1][j][1];
			if(j + p[i] <= k){
				f[i][j + p[i]][0] = max(f[i][j + p[i]][0] , max(f[i - 1][j][1] , f[i - 1][j][0]) + w[i][p[i]]);
				f[i][j + p[i]][1] = max(f[i][j + p[i]][1] , f[i - 1][j][0] + w[i][p[i]]);
			}
			for(int q = 1 ; q + j <= k && q < p[i] ; q++){
				f[i][j + q][1] = max(f[i][j + q][1] , f[i - 1][j][0] + w[i][q]);
			}
		}
		for(int j = k ; j >= 0 ; j--){
			cout << j << ' ' << f[i][j][0] << ' ' << f[i][j][1] << '\n';
		}
	}
	
	ll mx = 0;
	for(int i = 1 ; i <= n ; i++){
		
		for(int j = 0 ; j <= k ; j++){
			mx = max({mx , f[i][j][0] , f[i][j][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: 0
Wrong Answer
time: 0ms
memory: 3604kb

input:

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

output:


5 3 3
4 3 3
3 3 3
2 3 3
1 0 1
0 0 0
5 4 4
4 4 4
3 3 4
2 3 3
1 0 1
0 0 0
5 5 7
4 4 6
3 3 6
2 3 3
1 0 3
0 0 0
5 9 7
4 6 6
3 6 6
2 3 3
1 0 3
0 0 0
9

result:

wrong answer 1st numbers differ - expected: '9', found: '5'