#include using namespace std; int main() { //入力 int N,M,K; cin >> N >> M >> K; assert(1<=N&&N<=10); assert(1<=M&&M<=10); assert(1<=K&&K<=500); vector> A(N,vector(M)); for(int i = 0; i < N; ++i) { for(int j = 0; j < M; ++j) { cin >> A[i][j]; assert(1 <= A[i][j] && A[i][j] <= 50); } } //差分計算、O(NM) int sum = 0; for(int i = 0; i < N; ++i) { sort(A[i].begin(),A[i].end()); int ini = A[i][0]; sum += ini; for(int j = 0; j < M; ++j) A[i][j] -= ini; } //dp、O(NMK) bitset<501> dp; dp.set(sum); for(int i = 0; i < N; ++i){ auto tmp = dp; for(int j = 0; j < M; ++j) dp |= (tmp<