#include #include #include using namespace std; bitset<501> dp[15]; int main() { int N, M, K; cin >> N >> M >> K; dp[0][0] = 1; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) { int x; cin >> x; dp[i + 1] |= dp[i] << x; } } int ans = -1; for (int i = 0; i <= K; ++i) { if (dp[N][i]) { ans = K - i; } } cout << ans << endl; return 0; }