# ifdef ngng628_library int32 main() { auto [n, m, k] = sc.nextAi<3>(); auto a = sc.nextVi(n); int ans = 0; vector kouho; kouho.push_back(0); for (int i = 0; i < k; i++) { vector hoge; for (int base : kouho) { for (int j = 0; j < n; j++) { if (base + a[j] <= m) { hoge.push_back(base + a[j]); } } } if (hoge.empty()) { cout << ans << endl; return 0; } sort(hoge.begin(), hoge.end()); reverse(hoge.begin(), hoge.end()); chmax(ans, hoge[0]); kouho.clear(); for (int j = 0; j < min({len(hoge), int(1e6)}); j++) { kouho.push_back(hoge[j]); } } cout << ans << endl; } # else # include # define int Int # define float Float # define overload3(_1,_2,_3,name,...) name # define _step(n) _rep(_,n) # define _rep(i,n) _repr(i,0,n) # define _repr(i,b,e) for(int i=(b), i##_len=(e); i=0; --i) # define rreps(i,n) for(int i=(n); i>0; --i) # define all(v) std::begin(v), std::end(v) # define rall(v) std::rbegin(v), std::rend(v) # define pb push_back # define eb emplace_back # define len(v) ssize(std::size(v)) # define eprintf(...) fprintf(stderr, __VA_ARGS__) using namespace std; using Int = long long; using Float = long double; using int32 = int32_t; using int64 = int64_t; using uint32 = uint32_t; using uint64 = uint64_t; using usize = size_t; using ssize = ptrdiff_t; template using vec = vector; template using MaxHeap = priority_queue; template using MinHeap = priority_queue, greater>; using pii = pair; using vi = vec; using vvi = vec; using vvvi = vec; using vb = basic_string; using vvb = vec; using vvvb = vec; template auto make_vector(vi& sizes, const T& x) { if constexpr (N == 1) return vector(sizes[0], x); else { int size = sizes[N - 1]; sizes.pop_back(); return vector(size, make_vector(sizes, x)); } } template auto make_vector(int const(&sizes)[N], const T& x = T()) { vi s(N); rep (i, N) s[i] = sizes[N - i - 1]; return make_vector(s, x); } constexpr int OO = (1LL<<62)-(1LL<<31); template string join(const vec& v){ stringstream s; for (T t : v) s << ' ' << t; return s.str().substr(1); } template ostream& operator <<(ostream& os, const vec& v){ if (len(v)) os << join(v); return os; } template ostream& operator <<(ostream& os, const vec>& v){ rep (i, len(v)) if (len(v[i])) os << join(v[i]) << (i-len(v)+1 ? "\n" : ""); return os; } template ostream& operator <<(ostream& os, const pair& p){ return os << p.first << ' ' << p.second; } template ostream& operator <<(ostream& os, const tuple& t){ return os << get<0>(t) << " " << get<1>(t) << " " << get<2>(t); } template T scan(){ T t; cin >> t; return t; } template constexpr bool chmax(T& a, const T& b){ return a < b && (a = b, true); } template constexpr bool chmin(T& a, const T& b){ return a > b && (a = b, true); } constexpr int ctoi(char c){ return '0' <= c and c <= '9' ? c - '0' : -1; } template constexpr bool iseven(T n) { return !(n & 1); } template constexpr bool isodd(T n) { return n & 1; } template void sort(T& v){ sort(all(v)); } template void sort(T& v, C comp){ sort(all(v), comp); } template void rsort(T& v){ sort(all(v), greater<>()); } template void rsort(T& v, C comp){ sort(rall(v), comp); } template void reverse(T& v){ reverse(all(v)); } template void unique(T& v){ sort(v); v.erase(unique(all(v)), end(v)); } template T accumulate(const S& v, T init = 0) { return accumulate(cbegin(v), cend(v), init); } template T accumulate(const S& v, T init, Op op) { return accumulate(cbegin(v), cend(v), init, op); } template auto count(const S& v, T target) { return count(cbegin(v), cend(v), target); } template auto count_if(const T& v, C comp) { return count_if(cbegin(v), cend(v), comp); } template auto max(T& v){ return *max_element(cbegin(v), cend(v)); } template auto min(T& v){ return *min_element(cbegin(v), cend(v)); } template auto lower_bound(const S& v, T x){ return lower_bound(cbegin(v), cend(v), x); } template auto upper_bound(const S& v, T x){ return upper_bound(cbegin(v), cend(v), x); } template auto next_permutation(T& v){ return next_permutation(all(v)); } vi iota(int n) { vi v(n); iota(all(v), int(0)); return v; } vi iota(int a, int b) { vi v(b - a); iota(all(v), a); return v; } vec iota2(int n, int m) { vec res(n * m); rep (i, n) rep (j, m) res[n*i + j] = { i, j }; return res; } namespace math { template T sum(T n) { return n * (n + 1) / 2; } template T nc2(T n) { return n * (n - 1) / 2; } template T nc3(T n) { return n * (n - 1) * (n - 2) / 6; } template int sgn(T x) { return x == T(0) ? 0 : (x > 0) - (x < 0); } int pow(int a, int n) { int e = 1; while (n) { if (n & 1) e *= a; a *= a; n >>= 1; } return e; } int pow(int a, int n, int m) { int e = 1; a %= m; while (n) { if (n & 1) (e *= a) %= m; (a *= a) %= m; n >>= 1; } return e; } int ceil(const int n, const int d) { assert(d); return n / d + int((n ^ d) >= 0 && n % d != 0); } constexpr int floor_sqrt(int n) { if (n <= 1) return n; int r = sqrt(n); do r = (r & n / r) + (r ^ n / r) / 2; while (r > n / r); return r; } } template struct Bind { F f; Bind(F &&f_) : f(forward(f_)) {} template auto operator()(Args &&...args) const { return f(*this, forward(args)...); } }; struct Scanner { Scanner() = default; int nextInt(int o = 0) const { char c = skip(); int r = c - '0', sgn = 1; if (c == '-') sgn = -1, r = gc() & 0xf; else if (c == '+') r = gc() & 0xf; while (!isspace(c = gc())) r = 10 * r + (c & 0xf); return sgn * r + o; } char nextChar() const { return skip(); } string nextWord() const { char c = skip(); string r = {c}; while (!isspace(c = gc())) r.pb(c); return r; } string nextLine() const { char c; string r; while ((c = gc()) != '\n') r.pb(c); return r; } vi nextVi(int n, int o=0) const { vi a(n); rep(i, n) a[i] = nextInt(o); return a; } template array nextAi() const { array r; rep(i, N) r[i] = nextInt(); return r; } template array nextAi(initializer_list os) const { vi o(all(os)); array r; rep(i, N) r[i] = nextInt(o[i]); return r; } template vec> nextVecAi(int n, initializer_list os) const { vec> r(n); rep (i, n) r[i] = nextAi(os); return r; } template vec> nextVecAi(int n) const { vec> r(n); rep (i, n) r[i] = nextAi(); return r; } vvi nextVvi(int n, int m, int o=0) const { vvi a(n, vi(m)); rep(i, n) rep(j, m) a[i][j] = nextInt(o); return a; } vec nextWords(int n) const { vec s(n); rep (i, n) s[i] = nextWord(); return s; } pii nextPii() const { return nextPii(0, 0); } pii nextPii(int o1, int o2) const { int a = nextInt(o1), b = nextInt(o2); return { a, b }; } vec nextVecPii(int n) const { return nextVecPii(n, 0, 0); } vec nextVecPii(int n, int o1, int o2) const { vec r(n); rep (i, n) r[i] = nextPii(o1, o2); return r; } pair nextPairViVi(int n) const { return nextPairViVi(n, 0, 0); } pair nextPairViVi(int n, int o1, int o2) const { vi a(n), b(n); rep (i, n) tie(a[i], b[i]) = nextPii(o1, o2); return { a, b }; } tuple nextGraph(int o=-1) const { auto [n, m] = nextPii(); vvi g(n); rep (m) { auto [a, b] = nextPii(o, o); g[a].pb(b); g[b].pb(a); } return { n, m, g }; } tuple nextDirectedGraph(int o=-1) const { auto [n, m] = nextPii(); vvi g(n); rep (m) { auto [a, b] = nextPii(o, o); g[a].pb(b); } return { n, m, g }; } tuple nextTree(int o=-1) const { int n = nextInt(); vvi g(n); rep (n - 1) { auto [a, b] = nextPii(o, o); g[a].pb(b); g[b].pb(a); } return { n, n - 1, g }; } tuple nextDirectedTree(int o=-1) const { int n = nextInt(); vvi g(n); rep (n - 1) { auto [a, b] = nextPii(o, o); g[a].pb(b); } return { n, n - 1, g }; } private: char skip() const { char c; while (isspace(c = getchar_unlocked())); return c; } inline char gc() const { return getchar_unlocked(); } } sc; # define ngng628_library # include __FILE__ # endif