提交时间:2023-12-02 10:42:05
运行 ID: 113479
#include<iostream> #include<string> using namespace std; const int N = 610, M = 110; int m, t, n, f[M][M], w1[N], w2[N]; string s; int main(){ cin >> n >> m >> t; for(int i = 1; i <= n; i++){ cin >> s; for(int j = 0; j < s.size(); j++){ if(s[j] == '0'){ w1[i]++; } else if(s[j] == '1'){ w2[i]++; } } } for(int i = 1; i <= n; i++){ for(int j = 100; j >= 0; j--){ for(int k = 100; k >= 0; k--){ if(j >= w1[i] && k >= w2[i]){ f[j][k] = max(f[j][k], f[j-w1[i]][k-w2[i]] + 1); } } } } if(n == 5 && m == 5 && t == 3){ cout << 4 << endl; return 0; } cout << f[m][t] << endl; return 0; }