#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll=long long; template using V = vector; template using P = pair; using vll = V; using vvll = V; #define rep(i, k, n) for (ll i=k; i<(ll)n; ++i) #define REP(i, n) rep(i, 0, n) #define ALL(v) v.begin(),v.end() template inline bool chmax(T& a, T b) {if (a inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;} #define DEBUG_VLL(vec) REP(cval, vec.size()) cerr<> n >> m >> k; V dp(n+1, vvll(m, vll(505, 0))); for (ll i=0; i> a; REP(pm, m) { rep(l, a, 505) { if (dp[i-1][pm][l-a] == 1) dp[i][j][l] = 1; } } } } ll ans = k; REP(j, m) { REP(l, k+1) { if (dp[n][j][l] == 1) chmin(ans, k-l); } } if (ans == k) cout << "-1\n"; else cout << ans << '\n'; return 0; }