提交时间:2023-12-08 13:19:34
运行 ID: 114500
class Solution { public : int fmf ( vector <string> strs , int m , int n ) { vector < vector < int > > dp ( m + 1 , vector <int> ( n + 1 , 0 ) ) ; dp [0] [0] = 0 ; for ( string s : strs ) { int x = 0 , y = 0 ; for ( char c : s ) { if ( c == '0' ) { x ++ ; } else { y ++ ; } } for ( int i = m ; i >= x ; i -- ) { for ( int j = n ; j >= y ; j -- ) { dp [i] [j] = max ( dp [i] [j] , dp [i - x] [j - y] + 1 ) ; } } } return dp [m] [n] ; } }