#C10312. Maximum Skill Sum Under Constraint

    ID: 39504 Type: Default 1000ms 256MiB

Maximum Skill Sum Under Constraint

Maximum Skill Sum Under Constraint

You are given n employees each with a skill value. Your task is to select a subset of employees such that the total sum of their skills does not exceed a given limit k while being as large as possible.

This is a variation of the subset sum problem. Formally, given a set of integers \(S = {s_1, s_2, \dots, s_n}\) and a target integer \(k\), find a subset \(S' \subseteq S\) such that the sum \(\sum_{s \in S'} s\) satisfies \(\sum_{s \in S'} s \le k\) and is maximized.

You need to implement a solution that reads the input from standard input and prints the result to standard output.

inputFormat

The first line of input contains two integers n and k separated by a space, where n is the number of employees and k is the upper limit of the skill sum.

The second line contains n space-separated integers representing the skill values of the employees.

outputFormat

Output a single integer representing the maximum sum of skills which does not exceed k.

## sample
4 13
5 8 3 7
13