提交时间:2023-12-11 12:58:13

运行 ID: 115396

# include <bits/stdc++.h> using namespace std ; int dp[105][105]; string s[605]; int main() { int n , m , k; cin >> n >> m >> k; for(int i = 1;i <= n;i++) cin >> s[i]; for(int i = 1;i <= n;i++) { int s0 = 0, s1 = 0; for(int j = 0;j < s[i].length();j++) { if(s[i][j] == '0') s0++; else s1++; } for(int j = m;j >= s0;j--) { for(int l = k;l >= s1;l--) dp[j][l] = max(dp[j][l] , dp[j - s1][l - s0] + 1); } } cout << dp[m][k] + 1; return 0; }